How to download a file and get the path location locally

前端 未结 3 601
不思量自难忘°
不思量自难忘° 2020-12-07 05:20

I have a URL i.e http://downloadplugins.verify.com/Windows/SubAngle.exe . If i paste it on the tab and press enter then the file (SubAngle.exe) is getting downloaded and sav

3条回答
  •  悲&欢浪女
    2020-12-07 05:49

    easy and general function that im using:

    import org.apache.commons.io.FileUtils;
    
    public static void downLoadFile(String fromFile, String toFile) throws MalformedURLException, IOException {
            try {
                FileUtils.copyURLToFile(new URL(fromFile), new File(toFile), 60000, 60000);
    
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                System.out.println("exception on: downLoadFile() function: " + e.getMessage());
            }
        }
    

提交回复
热议问题