Interface MetaFile
-
public interface MetaFileProvides an abstraction for a file of aMetaDirectory.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcloseTempFile(boolean discard)Close the previously opened temporary file. ifdiscardisfalse, the contents of the temporary file are copied back to this file.voidcopyTo(File file, boolean preserveFileDate)Copies the contents of this file to the indicated platform file.voiddelete()Deletes the file from it's meta directoryMetaDirectorygetDirectory()Returns the meta directory that created this file.InputStreamgetInputStream()Open an input stream to this file.StringgetName()Returns the name of this file.StringgetPath()Returns a path of this file which is composed of the path of the meta directory and the name of this file.ReadergetReader()Opens a reader using the utf-8 encodinglonglastModified()Returns the last modified date of this file.longlength()Returns the length in bytes of this fileMD5md5()Returns the MD5 checksum of this file.voidmoveTo(MetaFile dst)Moves this file to another meta file of the same directoryFileopenTempFile()Opens a temporary file that is tied to this file and initializes it with the same content as this file.
-
-
-
Method Detail
-
getDirectory
MetaDirectory getDirectory()
Returns the meta directory that created this file.- Returns:
- the meta directory.
-
getPath
String getPath()
Returns a path of this file which is composed of the path of the meta directory and the name of this file.- Returns:
- the path
-
getName
String getName()
Returns the name of this file.- Returns:
- the name of this file.
-
getInputStream
InputStream getInputStream() throws IOException
Open an input stream to this file.- Returns:
- an input stream
- Throws:
IOException- if an I/O error occurs
-
getReader
Reader getReader() throws IOException
Opens a reader using the utf-8 encoding- Returns:
- a read
- Throws:
IOException- if an I/O error occurs
-
length
long length()
Returns the length in bytes of this file- Returns:
- the length.
-
md5
MD5 md5() throws IOException
Returns the MD5 checksum of this file. Note that this operation reads the file fully in order to calculate the checksum.- Returns:
- the MD5 checksum.
- Throws:
IOException- if an I/O error occurs
-
lastModified
long lastModified()
Returns the last modified date of this file.- Returns:
- the last modified
-
delete
void delete() throws IOExceptionDeletes the file from it's meta directory- Throws:
IOException- if an I/O error occurs
-
openTempFile
File openTempFile() throws IOException
Opens a temporary file that is tied to this file and initializes it with the same content as this file.- Returns:
- a temporary file.
- Throws:
IOException- if an I/O error occurs
-
closeTempFile
void closeTempFile(boolean discard) throws IOExceptionClose the previously opened temporary file. ifdiscardisfalse, the contents of the temporary file are copied back to this file.- Parameters:
discard-trueto discard the changes to the temp file- Throws:
IOException- if an I/O error occurs
-
moveTo
void moveTo(MetaFile dst) throws IOException
Moves this file to another meta file of the same directory- Parameters:
dst- destination file- Throws:
IOException- if an I/O error occurs
-
copyTo
void copyTo(File file, boolean preserveFileDate) throws IOException
Copies the contents of this file to the indicated platform file.- Parameters:
file- destination filepreserveFileDate-trueto update the modification date of the destination file- Throws:
IOException- if an I/O error occurs
-
-