issrg.utils
Class FileUtility

java.lang.Object
  extended by issrg.utils.FileUtility

public final class FileUtility
extends java.lang.Object

Utility class for working with files on the local file store.

Author:
sfl

Method Summary
static java.io.File createFile(java.lang.String fileName)
          Creates a File from a given fileName by looking in the classpath of the FileUtility class.
static java.io.File createFile(java.lang.String fileName, java.lang.Class<?> clazz)
          Creates a File from a given fileName by looking in the classpath of the given class.
static java.lang.String fileToString(java.io.File file)
          Returns the contents of a (text) file as a String object.
static java.lang.String fileToString(java.lang.String fileName)
          Returns the contents of a (text) file as a String object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fileToString

public static java.lang.String fileToString(java.io.File file)
                                     throws java.io.IOException
Returns the contents of a (text) file as a String object. The file will be read line by line.

Parameters:
file - the file that needs to be converted
Returns:
a String object with the contents of the file. Will be null if file is null
Throws:
java.io.IOException - when something went wrong while reading the file

fileToString

public static java.lang.String fileToString(java.lang.String fileName)
                                     throws java.io.IOException
Returns the contents of a (text) file as a String object. The file will be read line by line.

Parameters:
fileName - a String representing the file name of the file to be read
Returns:
a String object with the contents of the file.
Throws:
java.io.IOException - when something went wrong while reading the file
java.lang.NullPointerException - when fileName is null

createFile

public static java.io.File createFile(java.lang.String fileName)
Creates a File from a given fileName by looking in the classpath of the FileUtility class.

Parameters:
fileName - the file name of the file on the file system
Returns:
a File corresponding to the file or null if the file could not be created

createFile

public static java.io.File createFile(java.lang.String fileName,
                                      java.lang.Class<?> clazz)
Creates a File from a given fileName by looking in the classpath of the given class.

Parameters:
fileName - the file name of the file on the file system
clazz -
Returns:
a File corresponding to the file or null if the file could not be created