无需库
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
public class CopyOfTest {
public static void main(String[] args) throws MalformedURLException, IOException {
//java从网络下载文件 无需库
ReadableByteChannel readableByteChannel = Channels.newChannel(new URL("http://6.wjsou.com/uploads/filelist.txt").openStream());
FileOutputStream fileOutputStream = new FileOutputStream("out.txt");
fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
fileOutputStream.close();
System.out.print("end");
}
}
使用库Apache Commons IO