반응형
public static String getLocalHostAddress(){
String ip = null;
try(
final DatagramSocket socket = new DatagramSocket()){
socket.connect(InetAddress.getByName("9.9.9.9"), 0);
ip = socket.getLocalAddress().getHostAddress();
}
catch (Exception e){
e.printStackTrace();
}
return ip;
}
728x90
반응형
'Programing > Java' 카테고리의 다른 글
Proxy Object 란? (0) | 2023.03.13 |
---|---|
java PropertyDescriptor 란? (0) | 2023.03.13 |
java short - UUID 생성 (0) | 2019.12.26 |
java UUID생성 (0) | 2019.12.26 |
java hostname 추출 (0) | 2019.12.19 |
댓글