Java/Network
InetAddress 클래스 사용
krvision
2011. 12. 15. 19:23
import java.net.*; class InetAddressTest //InetAddress 클래스 사용 : ip를 추상화한 클래스 { public static void main(String[] args) { try{ InetAddress inet=null; inet=InetAddress.getByName(args[0]); // NetworkInterface mac; System.out.println("연결 됐습니다."); System.out.println("getHostName: "+inet.getHostName()); System.out.println("getHostAddress:" +inet.getHostAddress()); System.out.println("getLocalHost :" +inet.getLocalHost()); // System.out.println("Mac Address :" +mac.getHardwareAddress()); InetAddress[] inet2 = InetAddress.getAllByName("www.hanmail.net"); for (int i=0; i < inet2.length ;i++ ) { System.out.println(inet2[i]); } }catch(Exception e) { e.printStackTrace(); } }//mail()---- }////////////////////////////////