使用JAVA程序下载资源
public static void main(String[] args) throws IOException {
URL url = new URL("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3722825694,1670556258&fm=26&gp=0.jpg");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int code = connection.getResponseCode();
if (code==HttpURLConnection.HTTP_OK){
System.out.println("连接正常!");
InputStream is = connection.getInputStream();
FileOutputStream fos = new FileOutputStream("e:/1.jpg");
byte[] buf = new byte[1024];
int c=0;
while ((c = is.read(buf,0,buf.length))!=-1){
fos.write(buf,0,c);
}
fos.close();
is.close();
System.out.println("下载成功!");
}
}