publicstaticvoid main(String[] args) throws Exception { if (Util.isPrivileged()) {
System.out.println("Unable to test file permissions when running with privileges"); return;
}
File d = new File(System.getProperty("test.dir", "."));
File f = new File(d, "x.SetReadOnly");
if (f.exists()) { if (!f.delete()) thrownew Exception("Can't delete test file " + f);
} if (f.setReadOnly()) thrownew Exception("Succeeded on non-existent file: " + f);
OutputStream o = new FileOutputStream(f);
o.write('x');
o.close(); if (!f.setReadOnly()) thrownew Exception(f + ": Failed on file"); if (f.canWrite()) thrownew Exception(f + ": File is writeable");
f = new File(d, "x.SetReadOnly.dir"); if (f.exists()) { if (!f.delete()) thrownew Exception("Can't delete test directory " + f);
} if (!f.mkdir()) thrownew Exception(f + ": Cannot create directory"); if (f.setReadOnly() && f.canWrite()) thrownew Exception(f + ": Directory is writeable"); if (!f.delete()) thrownew Exception(f + ": Cannot delete directory");
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 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.