package testinetaddress; import java.net.InetAddress; import java.net.UnknownHostException; public class TestByName { public static void main(String[] args) { try { InetAddress address = InetAddress.getByName("www.georgelache.blogspot.com"); System.out.println(address.getHostName()); System.out.println(address); InetAddress[] addresses = InetAddress.getAllByName("www.google.com"); for (InetAddress addr : addresses) { System.out.println(addr); } InetAddress me = InetAddress.getLocalHost(); System.out.println(me); // This method can create // addresses for hosts that do not exist or cannot be resolved: byte[] addressB = {10, (byte)205, 20, 69}; InetAddress thatsme = InetAddress.getByAddress(addressB); System.out.println(thatsme); InetAddress thatsmeWithname = InetAddress.getByAddress("thatsme.com", addressB); System.out.println(thatsmeWithname); } catch (UnknownHostException ex) { System.out.println("Error!"); } } }
www.georgelache.blogspot.com
www.georgelache.blogspot.com/172.217.19.97
www.google.com/216.58.209.196
robuc-glache-d/10.205.20.69
/10.205.20.69
thatsme.com/10.205.20.69
Niciun comentariu:
Trimiteți un comentariu