Created
December 15, 2015 15:22
-
-
Save dataf3l/e3fcfef54ad5e8a54fb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.InetAddress; | |
import java.net.UnknownHostException; | |
class Inet { | |
public static void main(String args[]){ | |
String hostname = "Unknown"; | |
try | |
{ | |
InetAddress addr; | |
addr = InetAddress.getLocalHost(); | |
hostname = addr.getHostName(); | |
System.out.println(hostname); | |
} | |
catch (UnknownHostException ex) | |
{ | |
System.out.println("Hostname can not be resolved"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment