Esempio n. 1
0
 /** Return the hostname of the local machine. */
 public static String getLocalAddress() {
   String address = null;
   try {
     InetAddress ia = InetAddress.getLocalHost();
     address = ia.getHostAddress();
   } catch (UnknownHostException e) {
     return "127.0.0.1";
   }
   return address;
 }
Esempio n. 2
0
 /** Return the hostname of the local machine. */
 public static String getLocalHost() {
   String hostname = null;
   try {
     InetAddress ia = InetAddress.getLocalHost();
     hostname = ia.getHostName();
   } catch (UnknownHostException e) {
     return "localhost";
   }
   return hostname;
 }