LocalHost 추가
parent
0188c094e2
commit
16e682896b
@ -0,0 +1,35 @@
|
||||
package cokr.xit.foundation;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
public class LocalHost {
|
||||
private static final LocalHost obj = new LocalHost();
|
||||
|
||||
private String
|
||||
address,
|
||||
name,
|
||||
canonicalName;
|
||||
|
||||
public LocalHost() {
|
||||
try {
|
||||
InetAddress inetAddress = InetAddress.getLocalHost();
|
||||
address = inetAddress.getHostAddress();
|
||||
name = inetAddress.getHostName();
|
||||
canonicalName = inetAddress.getCanonicalHostName();
|
||||
} catch (Exception e) {
|
||||
throw Assert.runtimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String getAddress() {
|
||||
return obj.address;
|
||||
}
|
||||
|
||||
public static final String getName() {
|
||||
return obj.name;
|
||||
}
|
||||
|
||||
public static final String getCanonicalName() {
|
||||
return obj.canonicalName;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue