import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Properties;
public class WindowsTools
{
public static void main(String[] args) throws Exception
{
System.out.println(WindowsTools.getPhysicalAddress());
}
public static String getPhysicalAddress() throws Exception
{
Process p = Runtime.getRuntime().exec("cmd /c ipconfig -all");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
Properties props = System.getProperties();
System.out.println(props.getProperty("os.name"));
if ("Windows XP".equals(props.getProperty("os.name")))
{
while ((line = br.readLine()) != null && line.length() != 22)
{
}
while ((line = br.readLine()) != null && line.length() != 61)
{
}
return line.substring(61 - 17, 61);
} else
{
return "";
}
}
}
Java os PhysicalAddress
最新推荐文章于 2024-06-20 19:57:59 发布