The File object makes it easy to change the last modified time stamp on a file and the read/write status of a file. To perform these tasks, we use the setReadOnly() and setLastModified() methods of the File class. The setReadOnly() method, as you have probably guessed, sets the read/write status of the file on which the method is called to read-only. The setLastModified() method accepts a single parameter, specifying a time in milliseconds, and sets the file's last modified time to that time. The time value passed in is measured in milliseconds since the epoch (January 1, 1970, 00:00:00 GMT). Both of these methods will return a boolean value of true only if the operation is successful. If the operation fails for any reason, a value of false will be returned. |