at.gv.egovernment.moa.util
Class FileUtils

java.lang.Object
  |
  +--at.gv.egovernment.moa.util.FileUtils

public class FileUtils
extends Object

Utility for accessing files on the file system, and for reading from input streams.

Version:
$Id$
Author:
Paul Ivancsics

Constructor Summary
FileUtils()
           
 
Method Summary
static byte[] readFile(String filename)
          Reads a file, given by filename, into a byte array.
static String readFile(String filename, String encoding)
          Reads a file, given by filename, into a String.
static byte[] readResource(String name)
          Reads a file from a resource.
static String readResource(String name, String encoding)
          Reads a file from a resource.
static byte[] readURL(String urlString)
          Reads a file, given by URL, into a byte array.
static String readURL(String urlString, String encoding)
          Reads a file, given by URL, into a String.
 
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

readURL

public static byte[] readURL(String urlString)
                      throws IOException
Reads a file, given by URL, into a byte array.
Parameters:
urlString - file URL
Returns:
file content
Throws:
IOException - on any exception thrown

readURL

public static String readURL(String urlString,
                             String encoding)
                      throws IOException
Reads a file, given by URL, into a String.
Parameters:
urlString - file URL
encoding - character encoding
Returns:
file content
Throws:
IOException - on any exception thrown

readFile

public static byte[] readFile(String filename)
                       throws IOException
Reads a file, given by filename, into a byte array.
Parameters:
filename - filename
Returns:
file content
Throws:
IOException - on any exception thrown

readFile

public static String readFile(String filename,
                              String encoding)
                       throws IOException
Reads a file, given by filename, into a String.
Parameters:
filename - filename
encoding - character encoding
Returns:
file content
Throws:
IOException - on any exception thrown

readResource

public static byte[] readResource(String name)
                           throws IOException
Reads a file from a resource.
Parameters:
name - resource name
Returns:
file content as a byte array
Throws:
IOException - on any exception thrown

readResource

public static String readResource(String name,
                                  String encoding)
                           throws IOException
Reads a file from a resource.
Parameters:
name - filename
encoding - character encoding
Returns:
file content
Throws:
IOException - on any exception thrown