๐ป Programming/Java
ํ๋ก์ ํธ ํ์ฌ ๊ฒฝ๋ก ์ป๊ธฐ ( Getting current working directory )
์ผ์ด์น
2016. 6. 15. 19:49
์๋ฐ ํ๋ก๊ทธ๋จ์ ์ง๋ค๋ณด๋ฉด ํ์ฌ ํ๋ก์ ํธ์ 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.