develog

getAbsolutePath, getCanonicalPath 본문

Dev/Java

getAbsolutePath, getCanonicalPath

냐옴 2013. 6. 8. 22:17

// 현재 디렉토리

// C:\Documents and Settings\Administrator\workspace\testApp


1. getAbsolutePath (., .. 을 계산하지 않고 그대로 출력)

System.out.println(new File(".").getAbsolutePath());

System.out.println(new File("..").getAbsolutePath());


// output

C:\Documents and Settings\Administrator\workspace\testApp\.

C:\Documents and Settings\Administrator\workspace\testApp\..



2. getCanonicalPath (., .. 을 계산한 경로를 출력)

System.out.println(new File(".").getCanonicalPath());

System.out.println(new File("..").getCanonicalPath());


// output

C:\Documents and Settings\Administrator\workspace\testApp

C:\Documents and Settings\Administrator\workspace

'Dev > Java' 카테고리의 다른 글

UserException  (0) 2013.06.11
excel open protected password in jacob  (0) 2013.06.08
Jacob  (0) 2013.06.08
@Autowired 사용시 셋팅  (0) 2013.05.30
exception handling  (0) 2013.05.29
Comments