uk.ac.soton.itinnovation.grid.utils
Class FileUtils

java.lang.Object
  extended by uk.ac.soton.itinnovation.grid.utils.FileUtils

public class FileUtils
extends Object

Utility methods for handling files.


Constructor Summary
FileUtils()
           
 
Method Summary
static void copyFile(File src, File dest)
           
static File fileFromPath(String parent, String... children)
           
static String getStringFromFile(String fileName)
          Get a string out of a file given its filename
static String getStringFromResource(ClassLoader loader, String resourceName)
          Get a resource from a class loader and load it into a string.
static String getStringFromResource(String resourceName)
          Wrapper for getStringFromResource that uses FileUtils's own class loader.
static void mkdir(File dir)
           
static Document parseXML(byte[] bytes)
           
static Document parseXML(File xml)
           
static Document parseXML(InputStream is)
           
static Document parseXML(String xmlString)
           
static void rmTree(File dir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

getStringFromFile

public static String getStringFromFile(String fileName)
Get a string out of a file given its filename

Parameters:
fileName - the name of the file inc path
Returns:
a string containing the contents of the file

getStringFromResource

public static String getStringFromResource(String resourceName)
                                    throws IOException
Wrapper for getStringFromResource that uses FileUtils's own class loader. (the other method can probably be removed at some point)

Throws:
IOException

getStringFromResource

public static String getStringFromResource(ClassLoader loader,
                                           String resourceName)
                                    throws IOException
Get a resource from a class loader and load it into a string.

Parameters:
loader - the classloader (usually, getClass().getClassLoader())
resourceName - the full name of the resource to load
Returns:
a string containing the contents of the resource
Throws:
IOException

copyFile

public static void copyFile(File src,
                            File dest)
                     throws IOException
Throws:
IOException

rmTree

public static void rmTree(File dir)

parseXML

public static Document parseXML(String xmlString)

parseXML

public static Document parseXML(byte[] bytes)

parseXML

public static Document parseXML(InputStream is)

parseXML

public static Document parseXML(File xml)

mkdir

public static void mkdir(File dir)

fileFromPath

public static File fileFromPath(String parent,
                                String... children)


Copyright © 2001-2008 University of Southampton IT Innovation Centre. All Rights Reserved.