net.sf.rej.util
Class FileToolkit

java.lang.Object
  extended by net.sf.rej.util.FileToolkit

public class FileToolkit
extends java.lang.Object

FileToolkit class contains file utility functions.

Author:
Sami Koivu

Method Summary
static java.io.File createNewFile(java.io.File path, java.lang.String suffix)
           
static void deleteRecursively(java.io.File folder)
          Deletes a directory and all of it's subdirectories.
static byte[] readBytes(java.io.File f)
          Read the contents of the File into a byte array and return it.
static java.lang.String readFile(java.io.File f)
          Read the contents of File f into a String and return it.
static void writeBytes(java.io.File f, byte[] bytes)
          Write bytes[] into File f.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readFile

public static java.lang.String readFile(java.io.File f)
                                 throws java.io.IOException
Read the contents of File f into a String and return it.

Parameters:
f - Indicates the file to read.
Returns:
String Contents of File f
Throws:
java.io.IOException - - Exception while reading file

readBytes

public static byte[] readBytes(java.io.File f)
                        throws java.io.IOException
Read the contents of the File into a byte array and return it.

Parameters:
f - File The File to read.
Returns:
byte[] Contents of File f.
Throws:
java.io.IOException - Exception while reading file

writeBytes

public static void writeBytes(java.io.File f,
                              byte[] bytes)
                       throws java.io.IOException
Write bytes[] into File f. Overwriting the file if it exists.

Parameters:
f - File File to create/overwrite
bytes - byte[] data to write into the file
Throws:
java.io.IOException - Exception while writing file

deleteRecursively

public static void deleteRecursively(java.io.File folder)
                              throws java.io.IOException
Deletes a directory and all of it's subdirectories.

Parameters:
folder - File file or directory to delete.
Throws:
java.io.IOException - Exception while deleting

createNewFile

public static java.io.File createNewFile(java.io.File path,
                                         java.lang.String suffix)