File f = new File(System.getProperty("test.dir", "."), "x.CreateNewFile"); if (f.exists() && !f.delete()) thrownew Exception("Cannot delete test file " + f); if (!f.createNewFile()) thrownew Exception("Cannot create new file " + f); if (!f.exists()) thrownew Exception("Did not create new file " + f); if (f.createNewFile()) thrownew Exception("Created existing file " + f);
try {
f = new File("/"); if (f.createNewFile()) thrownew Exception("Created root directory!");
} catch (IOException e) { // Exception expected
}
testCreateExistingDir();
}
// Test JDK-6198547 privatestaticvoid testCreateExistingDir() throws IOException {
File tmpFile = new File("hugo"); if (tmpFile.exists() && !tmpFile.delete()) thrownew RuntimeException("Cannot delete " + tmpFile); if (!tmpFile.mkdir()) thrownew RuntimeException("Cannot create dir " + tmpFile); if (!tmpFile.exists()) thrownew RuntimeException("Cannot see created dir " + tmpFile); if (tmpFile.createNewFile()) thrownew RuntimeException("Should fail to create file " + tmpFile);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.