gethostname.java
来自「JSON(javascript) object creator and exam」· Java 代码 · 共 30 行
JAVA
30 行
import java.net.*;class getHostName { public static void main (String args[]) { try { byte [] ip = { 208-256, 201-256, 239-256, 36 }; InetAddress address = InetAddress.getByAddress(ip); System.out.println(address); address = InetAddress.getByName("100.0.2.52"); System.out.println(address.getHostName()); System.out.println(address.getHostAddress() ); address = InetAddress.getByName("208.201.239.36"); System.out.println(address.getHostName()); System.out.println(address.getHostAddress() ); } catch (UnknownHostException e) { System.out.println("Could not find host"); } catch (java.io.IOException e) { System.out.println("Could not reach host"); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?