package com.g;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class Urldowm {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
URL url = new URL("https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E5%9B%BE%E7%89%87&step_word=&hs=0&pn=1&spn=0&di=145420&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=1514002029%2C2035215441&os=1877667074%2C2954420195&simid=3455148517%2C365567886&adpicid=0&lpn=0&ln=1710&fr=&fmq=1630062936810_R&fm=&ic=undefined&s=undefined&hd=undefined&latest=undefined©right=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fimg.16pic.com%2F00%2F88%2F44%2F16pic_8844212_s.jpg%26refer%3Dhttp%3A%2F%2Fimg.16pic.com%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1632654939%26t%3Db864746ac00505c6fc26f05a6643700f&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3B8mrtv_z%26e3Bv54AzdH3Ff7vwtAzdH3F9cdlndl_z%26e3Bip4s&gsm=2&rpstart=0&rpnum=0&islist=&querylist=&nojc=undefined");
HttpURLConnection openConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = openConnection.getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream("D://123456.jpg");
byte[] name = new byte[1024];
int i;
while ((i=inputStream.read(name))!=-1) {
fileOutputStream.write(name, 0, i);
}
System.out.println("ok");
fileOutputStream.close();
inputStream.close();
openConnection.disconnect();
}
}
02-18
640
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-09