⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nettool.java

📁 用java写的可以提取你的主机名和ip地址和MAC地址
💻 JAVA
字号:
import java.net.*; 
public class NetTool{ 
InetAddress myIPaddress=null; 
InetAddress myServer=null; 
InetAddress myHostname=null;

public static void main( String args[]){ 

NetTool mytool; 
mytool=new NetTool(); 
/*try {
	String   serverName   =   java.net.InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}  */ 
System.out.println("Your host IP is: " + mytool.getMyIP()); 
//System.out.println("The Server IP is :" +mytool.getServerIP()); 
try {
	System.out.println("Your host Name is: " + java.net.InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
} 
} 

//取得LOCALHOST的IP地址 
public InetAddress getMyIP() { 
try { myIPaddress=InetAddress.getLocalHost();} 
catch (UnknownHostException e) {} 
return (myIPaddress); 
} 
//取得 www.abc.com 的IP地址 
/*public InetAddress getServerIP(){ 
try {myServer=InetAddress.getByName("www.abc.com");} 
catch (UnknownHostException e) {} 
return (myServer); 
} */

} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -