일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
Tags
- javascript
- 웹프로그래밍
- 공부를열심히
- orcle
- 객제지향프로그래밍
- html
- 주말이다..
- 오라클
- Oracle
- web
- Java
- 데이터베이스
- 코딩
- 객제지향
- 객체지향
- squery
- 공부
- Project
- CSS
- UI
- sql
- ERWin
- 프로젝트
- DB
- 웹
- 프로그래밍
- 객체지향프로그래밍
- 테이블
- jsp
- 자바
Archives
- Today
- Total
햄찌개
JAVA - InetAddress - IP주소 받아오는 예제 본문
ublic class InetAddressTest {
public static void main(String[] args) throws IOException {
// InetAddress 클래스 => IP주소를 다루기 위한 클래스
// naver 사이트의 ip정보 가져오기
InetAddress naverIp = InetAddress.getByName("www.naver.com");
//호스트 이름은 머신이름 , 도메인명, 또는 ip주소 문자열.
System.out.println("Host Name : "+naverIp.getHostName());
System.out.println("Host Address : "+naverIp.getHostAddress());
System.out.println();
//자기 자신 컴퓨터의 Ip주소
InetAddress localIp = InetAddress.getLocalHost();
System.out.println("내 컴퓨터의 Host Name : "+localIp.getHostName());
System.out.println("내 컴퓨터의 Host Address : "+localIp.getHostAddress());
System.out.println();
//ip주소가 여러개인 호스트의 정보 가져오기
InetAddress[] naverIps = InetAddress.getAllByName("www.youtube.com");
for (InetAddress nIp : naverIps) {
System.out.println(nIp.toString());
}
}
}
'고급 JAVA' 카테고리의 다른 글
JAVA-JDBC - 외부 properties (0) | 2020.09.29 |
---|---|
JAVA -JDBC - JDBC를 이용한 데이터베이스 처리 순서 (0) | 2020.09.29 |
JAVA - 입출력 - 호텔 관리 프로그램 예제 (0) | 2020.09.29 |
JAVA - 입출력 - image 카피 예제 (0) | 2020.09.29 |
JAVA - 입출력 - Serializable인터페이스 (0) | 2020.09.29 |