자바 프로젝트에서 현재 디렉토리 알아오기

Hoyoung Jung·2021년 1월 20일
1

자바로 프로젝트를 만들어서 진행하다 보면 종종 현재 디렉토리(current working directory)가 어디인지 몰라서 고생하는 경우가 있다.

그럴 때는 아래 코드로 간단히 알아낼 수 있다.

void foo() {
    System.out.println("Working Directory = " + System.getProperty("user.dir"));
    System.out.println("Working Directory = " + new File(".").getAbsolutePath());
}
profile
주짓수를 좋아하는 개발자

1개의 댓글

comment-user-thumbnail
2021년 1월 22일

앗 이거 까먹고 있었는데 고맙습니당ㅋㅋ

답글 달기