Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 전화걸기
- 국제화
- mybatis
- oracle
- 클래스
- 이클립스
- Eclips
- struts2
- Menu
- 메소드
- Java
- 메서드
- 생성자
- 배열
- 오버로딩
- paint
- 안드로이드
- JSP
- layout
- Spring
- OGNL
- AWT
- 어노테이션
- 기본
- Android
- HTML
- 에러페이지
- Graphic
- JavaScript
- 예외처리
Archives
- Today
- Total
note
네트워크 본문
package com.basic; import java.net.InetAddress; import java.net.UnknownHostException; import java.io.BufferedReader; import java.io.InputStreamReader; public class InetAddressTest02 { public static void main(String [] args) throws Exception{ BufferedReader reader; String url = null; InetAddress addr = null; reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("웹사이트 주소를 입력하세요 ->"); url = reader.readLine(); try{ addr = InetAddress.getByName(url); }catch(UnknownHostException e){ e.printStackTrace(); } System.out.println("=========================="); //getHostAddress(); System.out.println(url+"의 IP 번호 = "+addr.getHostAddress()); } }
package com.basic; import java.net.URL; import java.io.IOException; import java.net.MalformedURLException; public class URLEx { public static void main(String[] args) throws MalformedURLException, IOException{ URL url = new URL("http://java.sun.com/index.jsp?name=syh1011#content"); System.out.println("프로토콜 : "+url.getProtocol()); System.out.println("호스트 : "+url.getHost()); System.out.println("포트 : "+url.getDefaultPort()); System.out.println("패스 : "+url.getPath()); System.out.println("Query: "+url.getQuery()); System.out.println("reference: "+url.getRef()); System.out.println("주소: "+url.toExternalForm()); } }
package com.basic; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; public class NetworkEx4 { public static void main(String[] args) { URL url = null; BufferedReader input = null; String address = "http://www.google.co.kr"; String line = ""; try{ //URL : 인터넷 URL 주소를 추상화 하는 클래스 url = new URL(address); //url.openStream() : URL객체에 저장된 URL주소의 데이터를 InputStream으로 반환 input = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8")); while((line = input.readLine()) !=null) { System.out.println(line); } input.close(); }catch(Exception e){ e.printStackTrace(); } } }