public void testGet() throws IOException {
String str="http://meeket.gensee.com/";
URL url = new URL(str);
HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
urlcon.connect();//获取连接
InputStream is = urlcon.getInputStream();
BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
StringBuffer bs = new StringBuffer();
String l = null;
while((l=buffer.readLine())!=null){
bs.append(l).append("/n");
}
System.out.println(bs.toString());
}
方法一
URL url = new URL("http://www.sina.com.cn");
URLConnection urlcon = url.openConnection();
InputStream is = urlcon.getInputStream();
方法二
URL url = new URL("http://www.yhfund.com.cn");
HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
InputStream is = urlcon.getInputStream();
方法三
URL url = new URL("http://www.yhfund.com.cn");
InputStream is = url.openStream();