可能重复:
Java : File.exists() inconsistencies when setting “user.dir”
为什么这样:
void test(){
print(new File("downloads/"));
print(new File("downloads/").getAbsoluteFile());
print(new File("C:\\someDir\\downloads\\"));
}
void print(File dir){
log.info(dir.getAbsolutePath() + " exists " + dir.exists() + " contains: " + (dir.list() != null ? dir.list().length : "") + " files");
}
打印出来:
C:\someDir\downloads exists true contains: 0 files
C:\someDir\downloads exists true contains: 1 files
C:\someDir\downloads exists true contains: 1 files
在Jenkins的Maven中作为WebStart奴隶通过JUnit执行时?