Package com.iizix.util
Class FileChangedChecker
java.lang.Object
com.iizix.util.FileChangedChecker
This class is used to check for file modifications of the file time stamp and/or the file size.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorDescriptionFileChangedChecker
(File file) Creates the file change checker instance.FileChangedChecker
(String fileName) Creates the file change checker instance.Method Summary
Modifier and TypeMethodDescriptionGets the file name being checked.boolean
Checks if the file has changed.boolean
isNewerThan
(File file) Checks if this file is newer than the one specified.boolean
isNewerThan
(String fileName) Checks if this file is newer than the one specified.long
Returns the time that the file denoted by this abstract pathname was last modified.long
length()
Returns the length of the file denoted by this abstract pathname.void
update()
Requests an update of the file size and last modification time, if the file has been changed.
Constructor Details
FileChangedChecker
Creates the file change checker instance.FileChangedChecker
Creates the file change checker instance.
Method Details
getFileName
Gets the file name being checked.- Returns:
- The file name specified in the constructor or the path to the file name when the instance was constructed with the File parameter.
hasChanged
public boolean hasChanged()Checks if the file has changed.- Returns:
- true if the file has changed in size or last modified time, false otherwise.
update
public void update()Requests an update of the file size and last modification time, if the file has been changed.lastModified
public long lastModified()Returns the time that the file denoted by this abstract pathname was last modified.- Returns:
- A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs.
length
public long length()Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.- Returns:
- The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist. Some operating systems may return 0L for pathnames denoting system-dependent entities such as devices or pipes.
isNewerThan
Checks if this file is newer than the one specified. A new time stamp is read, the stored one is not used.- Parameters:
file
- The file to compare last modified time with.- Returns:
- true if this file is newer than the one specified in the parameter, false otherwise.
isNewerThan
Checks if this file is newer than the one specified. A new time stamp is read, the stored one is not used.- Parameters:
fileName
- The file name to compare last modified time with.- Returns:
- true if this file is newer than the one specified in the parameter, false otherwise.