Java URL Download nio downloadFile(URL downloadUrl, File destination)

Here you can find the source of downloadFile(URL downloadUrl, File destination)

Description

download File

License

Apache License

Declaration

public static void downloadFile(URL downloadUrl, File destination) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;
import java.net.URL;
import java.nio.file.Files;

public class Main {
    public static void downloadFile(URL downloadUrl, File destination) throws IOException {
        System.out.println("Downloading file from URL: " + downloadUrl + " to destination: " + destination);
        Files.copy(downloadUrl.openStream(), destination.toPath());
    }//from  w  w  w .j  a  v a  2  s. c  om
}

Related

  1. downloadFile(String url, File output)
  2. downloadFile(String url, String localFilePath)
  3. downloadFile(String url, String location)
  4. downloadFile(String url, String location)
  5. downloadFile(String urlPath, String local)
  6. downloadFile(URL url, File output)
  7. downloadFile(URL url, File targetFile)
  8. downloadFileNIO(FileChannel fileChannel, SocketChannel socketChannel)
  9. downloadFileToDirectory(String url, File destination)