Job/Java

[Java] System 클래스 GetEnv()

reallllbro 2009. 9. 4. 14:32

import java.util.*;
public class GetEnv{
 public static void main(String[] args) {
  Map<String,String> envMap=System.getenv();
  Set key = envMap.keySet();
  Iterator it = key.iterator();
  while(it.hasNext()){
   String curKey = it.next().toString();
   System.out.format("%s=%s\n", curKey, envMap.get(curKey));

  }
 }

}

 

 /*
   - static Map<String,String> getenv();
     현재 시스템 환경을 스트링 형태의 맵으로 리턴한다.
     
   - static String getenv(String name);
     name에 지정된 환경 변수의 값을 얻는다.

 

     이소스를 수행한 결과는 윈도우의 커맨드 창에서 "set" 명령어를 치는
     결과와 동일하다.

 */