Advertisement
paulogp

IP address from host name

Jul 13th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         try {
  4.             java.net.InetAddress inetAdd = java.net.InetAddress.getByName("www.apple.com");
  5.             System.out.println("IP Address is: " + inetAdd.getHostAddress());
  6.         } catch (java.net.UnknownHostException e) {
  7.             System.err.println(e);
  8.         }
  9.     }
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement