As a part of a high quality outreach, some modifications are coming within the deliberate Java 25 launch with regard to file operations on Home windows. The File.delete
command will not delete read-only recordsdata on Home windows, and file operations on a path with a trailing area in a listing or file identify will now fail persistently on Home windows.
In a June 16 bulletin on Oracle’s inside.java weblog, David Delabassee, Oracle director of Java relations, mentioned File.delete
in JDK 25 has been modified on Home windows so it now fails and returns false
for normal recordsdata when the DOS read-only attribute is ready. Earlier than JDK 25, File.delete
would delete read-only recordsdata by eradicating the DOS read-only attribute earlier than deletion was tried. However as a result of eradicating the attribute and deleting the file aren’t a single atomic operation, this might outcome within the file remaining, with modified attributes. Functions that depend upon the earlier conduct needs to be up to date to clear the file attributes earlier than deleting recordsdata, Delabassee mentioned.
To make the transition simpler, a system property has been launched to revive the earlier conduct. Working File.delete
with -Djdk.io.File.allowDeleteReadOnlyFiles=true
will take away the DOS read-only attribute previous to deleting the file, restoring the legacy conduct.