📄 gethostname.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -