# 목적 특정 웹페이지를 띄우는게 아니라 특정 웹페이지를 호출해야함 # 방법 URLConnection객체를 사용 ## 예제 ```java 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(args[0]); 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); } } }; ``` ## 참고사이트 - http://blog.naver.com/PostView.nhn?blogId=umhyun2&logNo=70072901008 - http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040201&docId=64188804