lookup.java
来自「this gives details of the network progra」· Java 代码 · 共 29 行
JAVA
29 行
// Sample Jav Program// Looks up the IP address for a hostname and prints it out//import java.net.*; // need this for InetAddresspublic class Lookup { static public void main(String args[]) { // lookup the address of each hostname found on the command line for (int i=0;i<args.length;i++) { printAddress(args[i]); } } static void printAddress( String hostname ) { // use a try/catch to handle failed lookups try { InetAddress a = InetAddress.getByName(hostname); System.out.println(hostname + ":" + a.getHostAddress()); } catch (UnknownHostException e) { System.out.println("No address found for " + hostname); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?