@@ -0,0 +1,1675 @@
+package net;%0A%0Aimport java.net.URL;%0Aimport java.io.IOException;%0Aimport java.io.File;%0Aimport java.io.DataInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.ByteArrayOutputStream;%0A%0Apublic class DownloadFile %7B%0A    public static void main(String%5B%5D args) %7B%0A%0A        String picUrl = %22https://mazhuang.org/assets/images/qrcode.jpg%22;%0A%0A        String tempPath =System.getProperty(%22java.io.tmpdir%22);%0A        String fileName = String.valueOf(System.currentTimeMillis());%0A        int index = picUrl.lastIndexOf(%22.%22);%0A        String suffix = picUrl.substring(index);%0A        fileName += suffix;%0A        String filePath = tempPath + fileName;%0A%0A        System.out.println(%22file path: %22 + filePath);%0A%0A        boolean result = downloadPicture(picUrl, filePath);%0A        System.out.println(%22download result: %22 + result);%0A    %7D%0A%0A    public static boolean downloadPicture(String picUrl, String filePath) %7B%0A        URL url;%0A%0A        try %7B%0A            url = new URL(picUrl);%0A            DataInputStream dataInputStream = new DataInputStream(url.openStream());%0A%0A            FileOutputStream fileOutputStream = new FileOutputStream(new File(filePath));%0A            ByteArrayOutputStream output = new ByteArrayOutputStream();%0A%0A            byte%5B%5D buffer = new byte%5B1024%5D;%0A            int length;%0A%0A            while ((length = dataInputStream.read(buffer)) %3E 0) %7B%0A                output.write(buffer, 0, length);%0A            %7D%0A            fileOutputStream.write(output.toByteArray());%0A            dataInputStream.close();%0A            fileOutputStream.close();%0A            return true;%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        return false;%0A    %7D%0A%7D%0A

Add snippets: download file by Java