Here you can find the source of downloadFile(URL fileUrl, File out)
public static final void downloadFile(URL fileUrl, File out)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.URL; import java.util.Scanner; public class Main { public static final void downloadFile(URL fileUrl, File out) { try {/*from www .j a v a 2 s . c o m*/ PrintStream outStream = new PrintStream(out); Scanner connectionScanner = new Scanner(fileUrl.openStream()); while (connectionScanner.hasNextByte()) { outStream.println(connectionScanner.nextByte()); } } catch (IOException e) { e.printStackTrace(); } } }