URL 클래스를 이용한 웹 페이지 긁어오기

BufferedReader br = null;
  
  try {
   URL url = new URL("http://www.empas.com");
   br = new BufferedReader(new InputStreamReader(url.openStream()));
   
   String line = null;
   while ((line = br.readLine()) != null) {
    System.out.println(line);
   }
  } catch (MalformedURLException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  } finally {
   try {
    br.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
 }

Related Posts

답글 남기기

이메일 주소는 공개되지 않습니다.