package org.ibase4j.core.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class NativeUtil {
private static Logger logger = LogManager.getLogger();
private NativeUtil() {
}
/** 获取机器名 */
public static final String getHostName() {
String hostName = "";
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
logger.error(e.getMessage(), e);
}
return hostName;
}
/** 获取网卡序列号 */
public static final String getDUID() {
String address = "";
String command = "cmd.exe /c ipconfig /all";
try {
Process p = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf("DUID") > 0) {
int index = line.indexOf(":");
index += 2;
address = line.substring(index);
break;
}
}
br.close();
} catch (IOException e) {
}
return address;
}
}
java判断本地物理网卡 java获取网卡信息
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
centos 双网卡配置
双网卡
双网卡