Interface MetaFile
-
public interface MetaFile
Provides an abstraction for a file of aMetaDirectory
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
closeTempFile(boolean discard)
Close the previously opened temporary file.void
copyTo(File file, boolean preserveFileDate)
Copies the contents of this file to the indicated platform file.void
delete()
Deletes the file from it's meta directoryMetaDirectory
getDirectory()
Returns the meta directory that created this file.InputStream
getInputStream()
Open an input stream to this file.String
getName()
Returns the name of this file.String
getPath()
Returns a path of this file which is composed of the path of the meta directory and the name of this file.Reader
getReader()
Opens a reader using the utf-8 encodinglong
lastModified()
Returns the last modified date of this file.long
length()
Returns the length in bytes of this fileMD5
md5()
Returns the MD5 checksum of this file.void
moveTo(MetaFile dst)
Moves this file to another meta file of the same directoryFile
openTempFile()
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 IOException
Deletes 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 IOException
Close the previously opened temporary file. ifdiscard
isfalse
, the contents of the temporary file are copied back to this file.- Parameters:
discard
-true
to 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
-true
to update the modification date of the destination file- Throws:
IOException
- if an I/O error occurs
-
-