public static String getHostName(){
String hostname = System.getenv("HOSTNAME");
if(hostname != null) return hostname;
String lineStr = "";
try {
Process process = Runtime.getRuntime().exec("hostname");
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
while((lineStr = br.readLine()) != null ){
hostname = lineStr;
}
}catch (IOException e) {
e.printStackTrace();
hostname = "";
}
return hostname;
}
String hostname = System.getenv("HOSTNAME");
if(hostname != null) return hostname;
String lineStr = "";
try {
Process process = Runtime.getRuntime().exec("hostname");
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
while((lineStr = br.readLine()) != null ){
hostname = lineStr;
}
}catch (IOException e) {
e.printStackTrace();
hostname = "";
}
return hostname;
}
댓글
댓글 쓰기