|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.common.file.FileIO
public class FileIO
Implements simple utility methods for storing and retrieving files located under a base directory. This class is designed to support operations on both standard Linux file systems as well as Hadoop. For this reason we use the package-defined FileIOException as a covering exception for all underlying exception types instead of exceptions like IOException that only apply to on particular type of file system.
| Nested Class Summary | |
|---|---|
class |
FileIO.LocalFilenameFilter
Internal filter class to select file names based on a prefix. |
| Constructor Summary | |
|---|---|
FileIO()
|
|
| Method Summary | |
|---|---|
boolean |
delete(FilePath path)
Delete path. |
boolean |
delete(FilePath path,
boolean recursive)
Delete path and optionally any children. |
boolean |
exists(FilePath path)
Returns true if path exists. |
boolean |
isDirectory(FilePath path)
Returns true if path is a directory. |
boolean |
isFile(FilePath path)
Returns true if path is an ordinary file. |
java.lang.String[] |
list(FilePath path)
Return a list of the names of children of this path. |
java.lang.String[] |
list(FilePath path,
java.lang.String prefix)
Return a list of the names of children of this path that start with the given prefix. |
boolean |
mkdir(FilePath path)
Create path as a new directory. |
boolean |
mkdirs(FilePath path)
Create path as a new directory including any intervening directories in the path. |
java.lang.String |
read(FilePath path)
Returns the value of the contents of a file as a string using UTF-8 as charset encoding. |
java.lang.String |
read(FilePath path,
java.lang.String charset)
Returns the value of the contents of a file as a string. |
boolean |
readable(FilePath path)
Returns true if path is readable. |
boolean |
writable(FilePath path)
Returns true if path is writable. |
void |
write(FilePath path,
java.lang.String value)
Write data to file system using UTF-8 charset for file encoding and with flush only. |
void |
write(FilePath path,
java.lang.String value,
java.lang.String charset)
Write data to file system with flush only. |
void |
write(FilePath path,
java.lang.String value,
java.lang.String charset,
boolean fsync)
Writes a string into a file, replacing an existing contents. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileIO()
| Method Detail |
|---|
public boolean exists(FilePath path)
public boolean isFile(FilePath path)
public boolean isDirectory(FilePath path)
public boolean writable(FilePath path)
public boolean readable(FilePath path)
public java.lang.String[] list(FilePath path)
path - Path to search
public java.lang.String[] list(FilePath path,
java.lang.String prefix)
path - Path to searchprefix - Required file name prefix or null to return all children
public boolean mkdir(FilePath path)
path - Path to create
public boolean mkdirs(FilePath path)
path - Path to create
public boolean delete(FilePath path)
path - Path to delete
public boolean delete(FilePath path,
boolean recursive)
path - Path to deleterecursive - If true delete child files/directories as well
public void write(FilePath path,
java.lang.String value)
throws FileIOException
path - The file pathvalue - The string to write in the file
FileIOException - Thrown if file is not writable
public void write(FilePath path,
java.lang.String value,
java.lang.String charset)
throws FileIOException
path - The file pathvalue - The string to write in the filecharset - Character set of file data (e.g., UTF-8)
FileIOException - Thrown if file is not writable
public void write(FilePath path,
java.lang.String value,
java.lang.String charset,
boolean fsync)
throws FileIOException
path - The file pathvalue - The string to write in the filecharset - Character set of file data (e.g., UTF-8)fsync - If true issue an fsync, otherwise just flush
FileIOException - Thrown if file is not writable
public java.lang.String read(FilePath path)
throws FileIOException
path - The file path
FileIOException - Thrown if file is not readable
public java.lang.String read(FilePath path,
java.lang.String charset)
throws FileIOException
path - The file pathcharset - Character set of file data (e.g., UTF-8)
FileIOException - Thrown if file is not readable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||