📄 readmac.java.bak
字号:
import java.io.*;
class ReadMAC
{
public static String physicalAddress = "read MAC error";
public ReadMAC()
{
}
public static String checkPhysicalAddress()
{
try
{
String line;
Process process = Runtime.getRuntime().exec("C:\\WINDOWS\\system32\\ipconfig");
//Process process = Runtime.getRuntime().exec("cmd /c ipconfig /all");
//Process process = Runtime.getRuntime().exec("E:\\QQ\\QQ.exe" );
/*System.out.println("begin to read mac address" );
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
System.out.println( "hehe" );
while( ( line = br.readLine() ) != null )
{
if( line.indexOf( "Physical Address. . . . . . . . . :") != -1 )
{
if ( line.indexOf( ":" ) != -1 )
{
physicalAddress = line.substring( line.indexOf(":") + 2 );
break;
}
}
}
line = br.readLine();
System.out.println( line );
System.out.println( "ok" );
process.waitFor(); */
}
catch ( Exception e )
{
e.printStackTrace();
}
return physicalAddress;
}
public static void main(String[] args)
{
System.out.println("Hello World!");
System.out.println( "本机的MAC地址是:" + ReadMAC.checkPhysicalAddress() );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -