测试:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import sun.net.www.http.HttpClient;
import com.sun.org.apache.commons.collections.StaticBucketMap;
public class QueryHtmlDate {
public static String Url(String urlString){
try {
StringBuffer html=new StringBuffer();
URL url=new URL(urlString);
HttpURLConnection conn=(HttpURLConnection) url.openConnection();
InputStreamReader isr=new InputStreamReader(conn.getInputStream());
BufferedReader br=new BufferedReader(isr);
String temp;
while ((temp=br.readLine())!=null) {
html.append(temp).append("/n");
}
br.close();
isr.close();
return html.toString();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
}
public static void main(String[] args) {
System.out.println(QueryHtmlDate.Url("http://www.cjcp.com.cn/ajax_kj.php?jsoncallback=?&qs=2002001"));
}
}