public class FileEntry extends AbstractFileSystemEntry
| Constructor and Description |
|---|
FileEntry()
Construct a new instance without setting its path
|
FileEntry(java.lang.String path)
Construct a new instance with the specified value for its path
|
FileEntry(java.lang.String path,
java.lang.String contents)
Construct a new instance with the specified path and file contents
|
| Modifier and Type | Method and Description |
|---|---|
FileSystemEntry |
cloneWithNewPath(java.lang.String path)
Return a new FileSystemEntry that is a clone of this object, except having the specified path
|
java.io.InputStream |
createInputStream()
Create and return an InputStream for reading the contents of the file represented by this entry
|
java.io.OutputStream |
createOutputStream(boolean append)
Create and return an OutputStream for writing the contents of the file represented by this entry
|
long |
getSize()
Return the size of this file
|
boolean |
isDirectory()
Return false to indicate that this entry represents a file
|
void |
setContents(byte[] contents)
Set the contents of the file represented by this entry
|
void |
setContents(java.lang.String contents)
Set the contents of the file represented by this entry
|
void |
setContents(java.lang.String contents,
java.lang.String charset)
Set the contents of the file represented by this entry, using the specified charset.
|
java.lang.String |
toString() |
getGroup, getLastModified, getName, getOwner, getPath, getPermissions, lockPath, setGroup, setLastModified, setOwner, setPath, setPermissions, setPermissionsFromStringpublic FileEntry()
public FileEntry(java.lang.String path)
path - - the value for pathpublic FileEntry(java.lang.String path,
java.lang.String contents)
path - - the value for pathcontents - - the contents of the file, as a Stringpublic boolean isDirectory()
isDirectory in interface FileSystemEntryisDirectory in class AbstractFileSystemEntrypublic long getSize()
public void setContents(java.lang.String contents)
contents - - the String whose bytes are used as the contentspublic void setContents(java.lang.String contents,
java.lang.String charset)
throws java.io.UnsupportedEncodingException
contents - - the String whose bytes are used as the contentscharset - - the charset used to convert the string to a byte[]java.io.UnsupportedEncodingException - - if an error occurs converting the String to a byte[] using the specified charsetpublic void setContents(byte[] contents)
contents - - the byte[] used as the contentspublic java.io.InputStream createInputStream()
public java.io.OutputStream createOutputStream(boolean append)
append - - true if the OutputStream should append to any existing contents false if
any existing contents should be overwrittenFileSystemException - - if an error occurs creating or initializing the OutputStreampublic FileSystemEntry cloneWithNewPath(java.lang.String path)
path - - the new path value for the cloned file system entrypublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()