刚用到的,保留在此,以备查询。
try {
URL url = new URL(
"http://lh3.ggpht.com/_d4XrOKBCIPc/ScL_LIHMDAI/AAAAAAAAABI/mP8Dmd0h9XY/s72/error.png");
java.io.BufferedInputStream bis = new BufferedInputStream(url.openStream());
byte[] bytes = new byte[100];
OutputStream bos = new FileOutputStream(new File("C:\\index_logo.gif"));
int len;
while ( (len = bis.read(bytes)) > 0) {
bos.write(bytes, 0, len);
}
bis.close();
bos.flush();
bos.close();
}
catch (Exception e) {
e.printStackTrace();
}