public class FileEntry extends AbstractFileSystemEntry
| Constructor and Description |
|---|
FileEntry()
Construct a new instance without setting its path
|
FileEntry(String path)
Construct a new instance with the specified value for its path
|
FileEntry(String path,
String contents)
Construct a new instance with the specified path and file contents
|
| Modifier and Type | Method and Description |
|---|---|
FileSystemEntry |
cloneWithNewPath(String path)
Return a new FileSystemEntry that is a clone of this object, except having the specified path
|
InputStream |
createInputStream()
Create and return an InputStream for reading the contents of the file represented by this entry
|
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(String contents)
Set the contents of the file represented by this entry
|
void |
setContents(String contents,
String charset)
Set the contents of the file represented by this entry, using the specified charset.
|
String |
toString() |
getGroup, getLastModified, getName, getOwner, getPath, getPermissions, lockPath, setGroup, setLastModified, setOwner, setPath, setPermissions, setPermissionsFromStringpublic FileEntry()
public FileEntry(String path)
path - - the value for pathpublic boolean isDirectory()
isDirectory in interface FileSystemEntryisDirectory in class AbstractFileSystemEntrypublic long getSize()
public void setContents(String contents)
contents - - the String whose bytes are used as the contentspublic void setContents(String contents, String charset) throws UnsupportedEncodingException
contents - - the String whose bytes are used as the contentscharset - - the charset used to convert the string to a byte[]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 InputStream createInputStream()
public 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(String path)
path - - the new path value for the cloned file system entrypublic String toString()
toString in class ObjectObject.toString()Copyright © 2016. All rights reserved.