62,628
社区成员
发帖
与我相关
我的任务
分享
URL localURL = new URL("http://www.csdn.net");
URLConnection connection = localURL.openConnection();
HttpURLConnection httpURLConnection = (HttpURLConnection)connection;
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
httpURLConnection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8");
httpURLConnection.setRequestProperty("Connection","keep-alive");
InputStream in =httpURLConnection.getInputStream();
byte[] buf =new byte[4096];
int len = in.read(buf);
System.out.println(new String(buf,0,len));