InetAddress 클래스의 주요 메서드

CODEDRAGON Development/Java

반응형


 

InetAddress 클래스의 주요 메서드

·       InetAddress 클래스는 IP 주소를 객체화한 클래스입니다.

·       호스트 이름과 호스트에 대응하는 IP 주소를 있도록 메서드를 제공합니다.

 

 

메소드

설명

boolean equals(InetAddress other)

·       객체가 other객체와 같은 주소를 가지면 true 아니면 false 반환합니다.

byte[] getAddress()

·       InetAddress 객체의 실제IP주소를 바이트 배열로 리턴합니다.

String getHostAddress()

·       IP주소를 문자열로 반환합니다.

·       IP주소를 점으로 구분하는 10진수 형태로 반환합니다.

String  getHostName()

·       컴퓨터이름(호스트 이름, 도메인명) 나타내는 문자열로 반환합니다.

static InetAddress getLocalHost() throws UnknownHostException

·       현재 컴퓨터를 나타내는 InetAddress 객체를 반환합니다.

static InetAddress getByName(String hostname) throws UnknownHostException

·       호스트 네임으로 지정된 컴퓨터를 나타내는 InetAddress객체를 반환합니다.

static InetAddress[] getAllByName(String hostname) throws UnknownHostException

·       호스트 네임으로 지정된 모든 컴퓨터를 InetAddress배열로 반환합나다,

·       하나의 도메인 이름으로 여러대의 컴퓨터를 사용하는 경우를 나타내는 InetAddress객체들의 배열을 반환합니다.

·       호스트의 모든 IP주소에 대한 정보를 InetAddress배열로 반환합나다,

String toString()

·       IP 주소를 String 문자열로 오버라이딩한 메소드입니다.

·       String 문자열의 형식은 '호스트이름/IP주소'입니다.

·       InetAddress객체를 화면에 출력하면 codedragon.tistory.com/216.52.17.206

 

 


반응형