path1 [JAVA] File의 path를 가져오는 API getPath() : File에 입력된 경로 리턴getAbsolutePath() : File에 입력된 절대 경로 리턴getCanonicalPath() : Resolved 된 절대 경로 리턴getPath()getPath()는 File에 입력한 경로를 리턴한다.만약 인자로 전달한 경로가 상대 경로라면 getPath()도 상대 경로를 리턴한다.File file = new File("./path/to/file");File file2 = new File("path/to/file2");// 결과./path/to/filepath/to/file2getAbsolutePath()getAbsolutePath()는 현재 실행 중인 Workding directory에 File에 전달한 경로를 조합하여 절대 경로를 리턴한다.Fi.. 2022. 8. 24. 이전 1 다음 728x90