프로젝트경로 (1)

자바 프로그램을 짜다보면 현재 프로젝트의 root 경로를 필요로 할 때가 있다.


그럴 경우 아래처럼 


public static void main(String[] args) {
       
      System.out.println("Current Working Directory = " + System.getProperty("user.dir"));
}

System.getProperty 메서드에 user.dir 을 인자로 넣어주면 현재 프로젝트의 root 경로(absolute path)를 String 으로 반환합니다.


Use 'System.getProperty("user.dir")' method for getting current working directory as absolute path. The method returns a string value of the root path of the java project as an absolute path.