Java InetAddress.getHostName()/getHostAddress
import java.net.InetAddress; import java.util.Scanner; class Blog { public static void main(String[] args) throws Exception { new Byul(); } } class Byul { Scanner sc; Byul() { sc = new Scanner(System.in); while (true) { System.out.println("Host 이름을 입력하세요."); try { InetAddress ia = InetAddress.getByName(sc.next()); System.out.println("Computer NAME: " + ia.getHostName()); System.out.println("Computer IP: " + ia.getHostAddress()); } catch (Exception e) { System.out.println(e.getMessage()); } } } }

댓글
댓글 쓰기