Created
January 15, 2019 00:06
-
-
Save alpercalisir/1cac38ae20bfcd7f74a1e692c3d97505 to your computer and use it in GitHub Desktop.
This file contains 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.*; | |
public class IdentifyHostNameIP { | |
public static void main(String[] args) { | |
for (int i = 0; i < args.length; i++) { | |
try { | |
InetAddress address = InetAddress.getByName(args[i]); | |
System.out.print("Host name: " + address.getHostName() + " "); | |
System.out.println("IP address: " + address.getHostAddress()); | |
} | |
catch (UnknownHostException ex) { | |
System.err.println("Unknown host or IP address " + args[i]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment