Get system hostname in java

Get system hostname in java

package com.w3spoint;
 
import java.net.InetAddress;
 
public class NetworkingTest {
  public static void main(String args[]){
	try {
		InetAddress myHost = InetAddress.getLocalHost();
	        System.out.println(myHost.getHostName());
        } catch(Exception e) {
            e.printStackTrace();
        }
  }
}

Output

INDEL-L-28V8JC2
Content Protection by DMCA.com
Please Share