HttpClient httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager());
try {
//创建httpget.
String url[]={"http://www.sohu.com","http://www.baidu.com","http://www.sina.com"};
HttpGet httpget = null;
HttpResponse response = null;
for(int i = 0; i<url.length; i++){
httpget = new HttpGet(url[i]);
System.out.println("executing request " + httpget.getURI());
response = httpclient.execute(httpget);
System.out.println("响应状态:" + response.getStatusLine());
System.out.println("------------------------------------");
}
}finally {
httpclient.getConnectionManager().shutdown();
}
把输出的内容自动生成一个txt文件,我是新手,最好有源码,谢谢了!!
------解决方案--------------------------------------------------------
你这个像日志输出 你百度一下 log4j 看看别人写的例子