2.1. 긁기 ¶
긁 .
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class URLConn{
public static void main(String args[]){
URL url;//URL 객
URLConnection connection;//URL 객
InputStream is;//URL 기 Stream
InputStreamReader isr;
BufferedReader br;
try{
//URL객 고 URL ..
url = new URL("http://www.hufslife.com/");
connection = url.openConnection();
// 기 InputStream객 ..
is = connection.getInputStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
// ..
String buf = null;
while(true){
buf = br.readLine();
if(buf == null) break;
System.out.println(buf);
}
}catch(MalformedURLException mue){
System.err.println(" URL. : java URLConn http://hostname/path]");
System.exit(1);
}catch(IOException ioe){
System.err.println("IOException " + ioe);
ioe.printStackTrace();
System.exit(1);
}
}
};










