java下载网络文件

import java.io.File;

import java.net.URL;

 

import org.apache.commons.io.FileUtils;

 

public class DownloadUtil {

 

public static void downloadFromURL(String resourse)throws Exception{

URL url = new URL(resourse);

 

String fileName = System.currentTimeMillis() + resourse.substring(resourse.lastIndexOf("/"));

File filePath = new File("d:/tmp/")  ;

FileUtils.copyURLToFile(url, filePath);

}

 

}

你可能感兴趣的:(java 下载 网络文件)