我堅持沒有文件夾的事實。創建新目錄
private static File createNewTempDir() {
File baseDir = new File(System.getProperty("java.io.tmpdir"));
String baseNamePrefix = System.currentTimeMillis() + "_" + Math.random() + "-";
LOG.info(System.getProperty("java.io.tmpdir"));
File tempDir = new File(baseDir, baseNamePrefix + "0");
LOG.info(tempDir.getAbsolutePath());
tempDir.mkdirs();
if (tempDir.exists()) {
LOG.info("I would be happy!");
}
else {
LOG.info("No folder there");
}
return tempDir;
}
它有什麼問題嗎?我能得到的LOG,沒有文件夾是有...
確定該文件夾不存在嗎?你只有在它存在時纔會記錄它。 –
這似乎是'if(!tempDir.exists())'中的否定問題。這會打印出「我會很開心!」如果路徑不存在,並且「沒有文件夾」,如果它存在。 –
這個問題與螞蟻有什麼關係?我看不到它的任何用法。也許你應該刪除標籤。 – joergl