import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
public static String getAddress1()
{
String rtnVal= "";
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
System.out.println("Current IP address : " + ip.getHostAddress());
rtnVal = ip.getHostAddress();
} catch (Exception e) {
e.printStackTrace();
}
return rtnVal;
}
public static String getMacAddress1()
{
String rtnVal= "";
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
//System.out.println("Current IP address : " + ip.getHostAddress());
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
System.out.print("Current MAC address : ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
System.out.println(sb.toString());
rtnVal = sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return rtnVal;
}
https://link.coupang.com/a/NeK3r
https://link.coupang.com/a/NeLdJ
이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.