de.unidu.is.util
Class IOUtilities

java.lang.Object
  extended byde.unidu.is.util.IOUtilities

public class IOUtilities
extends java.lang.Object

A class with utility methods for IO.

Since:
2004-05-19
Version:
$Revision: 1.8 $, $Date: 2005/02/28 22:27:55 $
Author:
Henrik Nottelmann

Nested Class Summary
static interface IOUtilities.FileHandler
          An interface whose instances can handle a file (for arbitrary usage).
 
Constructor Summary
IOUtilities()
           
 
Method Summary
static void doForAllFiles(java.io.File dir, IOUtilities.FileHandler handler)
          Calls the file handler for every file (recursively) in this directory
static java.io.File[] findFiles(java.io.File dir)
          Returns all files (recursively) in the specified directory.
static java.lang.String load(java.io.File file)
          Loads the content of the file and returns it as a string.
static java.lang.String load(java.io.Reader reader)
          Loads the content of the reader and returns it as a string.
static java.lang.String load(java.net.URL url)
          Loads the content of the URL and returns it as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtilities

public IOUtilities()
Method Detail

load

public static java.lang.String load(java.io.File file)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException
Loads the content of the file and returns it as a string.

Parameters:
file - file to be read
Returns:
string content of the file
Throws:
java.io.FileNotFoundException - if the file is not found
java.io.IOException - if an IO error occurs

load

public static java.lang.String load(java.net.URL url)
                             throws java.io.IOException
Loads the content of the URL and returns it as a string.

Parameters:
url - URL whoose content is to be read
Returns:
string content of the URL
Throws:
java.io.IOException - if an IO error occurs

load

public static java.lang.String load(java.io.Reader reader)
                             throws java.io.IOException
Loads the content of the reader and returns it as a string.

Parameters:
reader - reader
Returns:
string content of the reader
Throws:
java.io.IOException - if an IO error occurs

findFiles

public static java.io.File[] findFiles(java.io.File dir)
Returns all files (recursively) in the specified directory. Might yield an OOME in very large directories, then it is better to use doForAllFiles(File, FileHandler).

Parameters:
dir - directory to search
Returns:
all files under this directory.

doForAllFiles

public static void doForAllFiles(java.io.File dir,
                                 IOUtilities.FileHandler handler)
Calls the file handler for every file (recursively) in this directory

Parameters:
dir - directory to search
handler - handler to be called for every file