public interface FileHandle extends Comparable<FileHandle>
FileSystem.| Modifier and Type | Method and Description |
|---|---|
void |
append(InputStream content)
If
isFile() returns true, appends the stream-given content to the file. |
void |
delete()
Deletes this file or (recursiv) this directory
|
boolean |
exists()
Indicates, whether the file referred to with the handle exists.
|
FileHandle |
getChild(String name)
Get a handle on the child with the given name.
|
long |
getCrc()
Delivers the crc checksum if
hasCrc() returns true, else returns 0 |
long |
getLastModified()
Get the last modification time of the referenced file in milliseconds.
|
String |
getName()
The name of the file (without path), or the last part of the name its a directory
|
OutputStream |
getOutputStream()
Returns an OutputStream to store content to the file or
null if writing is not allowed. |
FileHandle |
getParent()
Get a handle on the parent file.
|
String |
getPath()
The path of the file (including file name if
getType() delivers FileType.FILE). |
long |
getSize()
The size of the file in bytes, delivers 0 if
getType() is not FileType.FILE |
FileType |
getType()
Returns the
type of the file handle. |
boolean |
hasCrc()
Delivers
true if getType() == FileType.FILE) and the crc checksum could
be calculated (which may not work for some FileSystem's) |
boolean |
isDirectory()
|
boolean |
isFile()
|
List<FileHandle> |
listFiles()
Returns the files in the directory referenced by the handle.
|
InputStream |
load()
If
isFile() returns true, returns a stream handle on the file's content. |
void |
mkDirs()
Create all necessary directories up to this one.
|
void |
rename(String newName)
Rename this file or directory.
|
void |
save(InputStream content)
If
isFile() returns true, saves the stream-given content to the file. |
void |
setLastModified(long time)
Set the last modification time of the referenced file in milliseconds.
|
void |
swapWith(String path)
Swap the file with the another on stored at the given path.
|
compareToboolean exists()
true, iff the file exists.@NotNull FileType getType()
type of the file handle.boolean isFile()
boolean isDirectory()
@NotNull List<FileHandle> listFiles() throws IOException
IOException - If an error occurred accessing the file.de.espirit.firstspirit.server.io.InvalidOperationOnTypeException - If the file is no directory.void mkDirs()
throws IOException
Note: The creation process may partially succeed before failing!
IOException - If creating directories failed.de.espirit.firstspirit.server.io.InvalidOperationOnTypeException - If the file is no directory.@NotNull InputStream load() throws IOException
isFile() returns true, returns a stream handle on the file's content.InputStream or null.IOException - If an error occured accessing the file.de.espirit.firstspirit.server.io.InvalidOperationOnTypeException - If the file is no file.void save(InputStream content) throws IOException
isFile() returns true, saves the stream-given content to the file.
Note: The given InputStream will be closed when finished!
content - The content providing stream.IOException - If an error occurred writing the file.de.espirit.firstspirit.server.io.InvalidOperationOnTypeException - If the file is no file.void append(InputStream content) throws IOException
isFile() returns true, appends the stream-given content to the file.
Note: closes given InputStream when finished!
content - The content providing stream.IOException - If an error occurred writing the file.de.espirit.firstspirit.server.io.InvalidOperationOnTypeException - If the file is no file.@Nullable OutputStream getOutputStream() throws IOException
null if writing is not allowed.null if writing is not allowed.IOException - If an error occurred writing the file.de.espirit.firstspirit.server.io.InvalidOperationOnTypeException - If this handle is no file.String getName()
String getPath()
getType() delivers FileType.FILE).long getSize()
getType() is not FileType.FILEboolean hasCrc()
true if getType() == FileType.FILE) and the crc checksum could
be calculated (which may not work for some FileSystem's)long getCrc()
throws IOException
hasCrc() returns true, else returns 0IOExceptionvoid delete()
throws IOException
IOExceptionvoid rename(String newName) throws IOException
IOExceptionvoid swapWith(String path) throws IOException
path - The path to the file to be swapped.IOExceptionlong getLastModified()
void setLastModified(long time)
throws IOException
FileSystem
and, thus, may have no effect.time - The last modification time to set.IOException@Nullable FileHandle getParent() throws IOException
IOExceptionFileHandle getChild(String name) throws IOException
name - The name of the child file.IOExceptionCopyright © 2015 e-Spirit AG. All Rights Reserved. Build 5.1.408