package jp.co.ntt.lms.xmo.util;

import java.io.*;
import java.net.URLEncoder;

public class ServerEnvironment {
	//OS実行コマンド
	private static final String COMD = "/bin/hostname";
	//例外発生時の返却文字列
	private static final String ERROR = "getHostIDError";
	
	public static String getHostName() throws Exception{
		try{
			Runtime objRuntime = Runtime.getRuntime();
			Process objProcess = objRuntime.exec(COMD);
			InputStreamReader Isr = new InputStreamReader(objProcess.getInputStream());
			BufferedReader Br = new BufferedReader(Isr );
			String strHostName = URLEncoder.encode(Br.readLine(),"UTF-8");
			return strHostName;	
		}catch(Exception e){
			e.printStackTrace();
			return ERROR;	
		}
	}
}