|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.syncclient.common.FileSystemTools
public class FileSystemTools
This class supplies some methods of usefullness for the management of files and directories.
In particular it supplies methods for the creation and the reading of file and for the removal of a directory and of its everything content
Constructor Summary | |
---|---|
FileSystemTools()
|
Method Summary | |
---|---|
static void |
createFile(java.lang.String directoryName,
java.lang.String fileName,
byte[] content)
Create a new file in the specified directory using the given file name and content. |
static void |
createFile(java.lang.String directoryName,
java.lang.String fileName,
java.io.ByteArrayOutputStream byteStream)
Create a new file in the specified directory using the given file name and byteStream. |
static java.lang.String[] |
getAllFiles(java.lang.String directory,
java.lang.String extension)
Returns all files in the given directory filtering on the given extension. |
static byte[] |
getFile(java.lang.String fileName)
Returns the content of the file specified. |
static byte[] |
readFileBytes(java.io.File file)
Reads a file into a byte array given its filename |
static byte[] |
readFileBytes(java.lang.String filename)
Reads a file into a byte array given its filename |
static java.lang.String |
readFileString(java.io.File file)
Reads a file into a String given its filename |
static java.lang.String |
readFileString(java.io.InputStream is)
Reads a file into a String given an input stream. |
static java.lang.String |
readFileString(java.lang.String filename)
Reads a file into a String given its filename |
static void |
removeDirectoryTree(java.lang.String directoryName)
Delete a directory, his subdirectory and all files. |
static void |
writeFile(byte[] buf,
java.io.File file)
Writes the given bytes to the file with the given name |
static void |
writeFile(byte[] buf,
java.lang.String filename)
Writes the given bytes to the file with the given name |
static void |
writeFile(java.lang.String str,
java.io.File file)
Writes the given string to the file with the given name |
static void |
writeFile(java.lang.String str,
java.lang.String filename)
Writes the given string to the file with the given name |
static void |
writeTextFile(java.io.File file,
java.lang.String text,
boolean append)
Write the given text in the given file appending to or rewriting it accordingly to append. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileSystemTools()
Method Detail |
---|
public static void removeDirectoryTree(java.lang.String directoryName) throws java.lang.Exception
directoryName
- the name of the directory to remove.
java.lang.Exception
- if an error occurs.public static void createFile(java.lang.String directoryName, java.lang.String fileName, byte[] content) throws java.lang.Exception
If the directory it does not exist it will be created.
If already exists a file with the same name, this has deleted before create the new file.
directoryName
- the directory in which the file must be created.fileName
- the name of the filecontent
- the content of the file.
java.lang.Exception
- if an error occurs during creation.public static void createFile(java.lang.String directoryName, java.lang.String fileName, java.io.ByteArrayOutputStream byteStream) throws java.lang.Exception
If the directory it does not exist it will be created.
If already exists a file with the same name, this has deleted before create the new file.
directoryName
- the directory in which the file must be created.fileName
- the name of the filebyteStream
- the content of the file.
java.lang.Exception
- if an error occurs during creation.public static void writeTextFile(java.io.File file, java.lang.String text, boolean append) throws java.io.IOException
file
- the file to write to - NOT NULLtext
- the text to write - NULL, equivalent to blankappend
- if true the text is appended to the file, if false
the file is overwritten
java.io.IOException
- if an error occurspublic static byte[] getFile(java.lang.String fileName) throws java.io.IOException
fileName
- the name of the file.
java.io.IOException
- if the file not exits or if an I/O error occurs.public static java.lang.String[] getAllFiles(java.lang.String directory, java.lang.String extension)
directory
- the directory to listextension
- select only the files with this extension
public static void writeFile(java.lang.String str, java.io.File file) throws java.io.IOException
str
- the string to writefile
- the file name as a java.io.File
java.io.IOException
public static void writeFile(java.lang.String str, java.lang.String filename) throws java.io.IOException
str
- the string to writefilename
- the file name as a java.lang.String
java.io.IOException
public static void writeFile(byte[] buf, java.lang.String filename) throws java.io.IOException
buf
- the bytes to writefilename
- the file name as a java.lang.String
java.io.IOException
public static void writeFile(byte[] buf, java.io.File file) throws java.io.IOException
buf
- the bytes to writefile
- the file name as a java.io.File
java.io.IOException
public static byte[] readFileBytes(java.io.File file) throws java.io.IOException
file
- the filename (as java.io.File)
java.io.IOException;
java.io.IOException
public static byte[] readFileBytes(java.lang.String filename) throws java.io.IOException
filename
- the filename (as java.lang.String)
java.io.IOException;
java.io.IOException
public static java.lang.String readFileString(java.io.File file) throws java.io.IOException
file
- the filename (as java.io.File)
java.io.IOException;
java.io.IOException
public static java.lang.String readFileString(java.lang.String filename) throws java.io.IOException
filename
- the filename (as java.lang.String)
java.io.IOException;
java.io.IOException
public static java.lang.String readFileString(java.io.InputStream is) throws java.io.IOException
is
- the InputStream to read
java.io.IOException;
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |