import java.io.*;
import java.net.URL;
public class Love {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
System.out.println("Hello World!");
String fileName = "secLZW.zip"; //The file that will be saved on your computer
URL link = new URL(" http://www.hooklee.com/Papers/ICME2011_SecLZW.zip");
//The file that you want to download
//Code to download
InputStream in = new BufferedInputStream(link.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n = 0;
while (-1!=(n=in.read(buf)))
{
out.write(buf, 0, n);
}
out.close();
in.close();
byte[] response = out.toByteArray();
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(response);
fos.close();
//End download code
System.out.println("Finished");
}
}
一个简单的Visual C++窗口程序: