get host name

import java.net.*;
import java.io.*;

public class GetHostName{
 public static void main(String [] args) {
 try {
  InetAddress addr = InetAddress.getLocalHost();
  byte[] ipAddr = addr.getAddress();
  String hostname = addr.getHostName();
  System.out.println("hostname="+hostname);
  } catch (UnknownHostException e) {
  }

  }
}

Post a Comment

Copyright © Rough Record. Designed by OddThemes