0import java.io.*;
import java.net.*;
public class URLConnectionDemo {
/**URLConnection 连接对象的多大开流方法
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
URL url = new URL("http://localhost:8080/myWeb/demo.html");
URLConnection conn= url.openConnection();
InputStream in = conn.getInputStream();//开流
byte[] buf = new byte[1024*2];
int len= 0;
while((len = in.read(buf))!=-1){
System.out.println(new String(buf,0,len));
}
}
}