Advertisement
paulogp

Local host name and address

Jul 13th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. /* Get local host name and address */
  2. // netbeans
  3.  
  4.  
  5. import java.net.InetAddress;
  6. import java.net.UnknownHostException;
  7.  
  8. public class Main {
  9.     public static void main(String[] args) {
  10.         try {
  11.             System.out.println(InetAddress.getLocalHost().getHostName());
  12.             System.out.println(InetAddress.getLocalHost().getHostAddress());
  13.         } catch (UnknownHostException e) {
  14.             System.err.println(e);
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement