de.unikassel.android.sdcframework.util
Class FileUtils

Package class diagram package FileUtils
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.FileUtils

public final class FileUtils
extends Object

A static utility class providing functions for IO and file operations.


Field Summary
static int DEFAULT_BUFFER_SIZE
          The default buffer size
 
Constructor Summary
FileUtils()
           
 
Method Summary
static boolean copy(File source, File dest)
          Method to copy one file to another
static boolean copy(FileInputStream sourceStream, FileOutputStream destStream)
          Method to copy one file stream to another
static boolean copy(FileInputStream sourceStream, String destFilename)
          Method to copy a file from an input stream to another file
static boolean copy(String sourceFilename, String destFilename)
          Method to copy one file to another
static boolean deleteFile(String filename)
          Method to delete a file
static File fileFromPath(String pathToFile)
          Method to create a file object from a path to a file
static String fileNameFromPath(String pathToFile)
          Method to extract the filename from a path
static String readTextFileContent(String fileName)
          Does read the content of a text file
static String readTextFileContentFromArchive(ZipInputStream zipStream, String fileName)
          Does read the content of a text file from an archive stream if the file is contained in the archive
static String readTextStreamContent(InputStream in)
          Method to read input from text stream into a string
static boolean writeToTextFile(String text, String fileName)
          Does write text into a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default buffer size

See Also:
Constant Field Values
Constructor Detail

FileUtils

public FileUtils()
Method Detail

fileNameFromPath

public static final String fileNameFromPath(String pathToFile)
Method to extract the filename from a path

Parameters:
pathToFile - the path to the file
Returns:
the raw filename without path but with extension

fileFromPath

public static final File fileFromPath(String pathToFile)
Method to create a file object from a path to a file

Parameters:
pathToFile - the path to the file
Returns:
a file object

deleteFile

public static final boolean deleteFile(String filename)
Method to delete a file

Parameters:
filename - the file name and path to delete
Returns:
true if successful, false otherwise

copy

public static final boolean copy(String sourceFilename,
                                 String destFilename)
Method to copy one file to another

Parameters:
sourceFilename - the source file name and path
destFilename - the destination file name and path
Returns:
true if successful, false otherwise

copy

public static final boolean copy(FileInputStream sourceStream,
                                 String destFilename)
Method to copy a file from an input stream to another file

Parameters:
sourceStream - the source file stream
destFilename - the destination file name and path
Returns:
true if successful, false otherwise

copy

public static final boolean copy(File source,
                                 File dest)
Method to copy one file to another

Parameters:
source - the source file
dest - the destination file
Returns:
true if successful, false otherwise

copy

public static final boolean copy(FileInputStream sourceStream,
                                 FileOutputStream destStream)
Method to copy one file stream to another

Parameters:
sourceStream - the source file stream
destStream - the destination file stream
Returns:
true if successful, false otherwise

writeToTextFile

public static final boolean writeToTextFile(String text,
                                            String fileName)
Does write text into a file

Parameters:
text - the text to write
fileName - the filename
Returns:
the file content as string

readTextFileContent

public static final String readTextFileContent(String fileName)
Does read the content of a text file

Parameters:
fileName - the filename
Returns:
the file content as string

readTextStreamContent

public static final String readTextStreamContent(InputStream in)
Method to read input from text stream into a string

Parameters:
in - the input stream
Returns:
the string content from input stream

readTextFileContentFromArchive

public static final String readTextFileContentFromArchive(ZipInputStream zipStream,
                                                          String fileName)
Does read the content of a text file from an archive stream if the file is contained in the archive

Parameters:
zipStream - the archive stream
fileName - the filename in archive to read
Returns:
the uncompressed content of the file in the archive