The File Class
The Java File class is nothing like the Python file object, in spite of the name. It allows you to check the following attributes of a file:
Read
Write
Size
Last modification date
Directory or not a directory
It also provides the methods listed below to view a directory's contents, to create and delete directories, and to delete directory files:
canRead()— determines permission and access to read the file
canWrite()— determines read-only or read/write access
delete()— deletes the current file referenced by this file object
equals(File)— determines if the file referenced by this object is the same as the argument
exists()— determines if the file exists
getPath()— gets the file path (can be relative)
getAbsolutePath()— same as above, but resolves ...
Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.