Package com.qzf.util;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import Java.io.InputStream;
Import java.net.HttpURLConnection;
Import java.net.MalformedURLException;
Import Java.net.URL;
public class Readmdimg {
public static void Main (string[] args)Throws IOException {
HttpURLConnection con = (httpurlconnection)New URL ("Http://www.madeinchina.cn/gongshang/CorpSel/InfoShowImg.aspx?" Strcode=40e4972e6cf94e842c5574e9dcd4cedb5b42d00be36ab7e9886f8d2139c47c79 "). OpenConnection ();
Con.setrequestmethod ("GET");
String cookie ="ASP.NET_SESSIONID=1P4PCK552N2EXV45ACUONNM0; Userinfo=cardmunber=001000040762&logins=1&searchs=0&first_date=2017/11/9&end_date=2018/11/9 &IS_ZZ=0&CORP_NAME=%e5%bc%a0%e6%a0%8b%e6%a2%81&ADDS=1&LINKMAN=%e5%bc%a0%e6%a0%8b%e6%a2%81& tel=15995885383; fengye=rowcount=638577&pagecount=11611 ";
Con.setrequestproperty ("Cookies", cookies);
Con.setrequestproperty ("User-agent","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; trident/5.0) ");
Con.setrequestproperty ("Host","www.madeinchina.cn");
Con.setrequestproperty ("Accept","Text/html, Application/xhtml+xml, */*");
Con.setrequestproperty ("Accept-language", "ZH-CN");
Con.setrequestproperty ( "accept-encoding", Con.setrequestproperty ( "Referer", InputStream in = Con.getinputstream ();
FileOutputStream out = new fileoutputstream ( "E : \\gongshang.jpg ");
byte[] buf = new byte[1024];
int len =-1;
while ((len = In.read (buf)) > 0) {
Out.write (buf, 0, Len);
}
Out.flush ();
Out.close ();
In.close ();
Con.disconnect ();
}
}
Java httpurlconnection Download picture pictures are all "encrypted picture" text, how to solve?