org.priha.util
Class FileUtil

java.lang.Object
  extended by org.priha.util.FileUtil

public class FileUtil
extends java.lang.Object


Constructor Summary
FileUtil()
           
 
Method Summary
static void copyContents(java.io.InputStream in, java.io.OutputStream out)
          Just copies all bytes from in to out.
static void copyContents(java.io.Reader in, java.io.Writer out)
          Just copies all characters from in to out.
static java.util.Properties findProperties(java.lang.String[] propertyPaths)
          Takes a list of paths and attempts to locate a property file from the list.
static java.lang.String readContents(java.io.InputStream input, java.lang.String encoding)
          Reads in file contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

copyContents

public static void copyContents(java.io.Reader in,
                                java.io.Writer out)
                         throws java.io.IOException
Just copies all characters from in to out. The copying is performed using a buffer of bytes.

Parameters:
in - The reader to copy from
out - The reader to copy to
Throws:
java.io.IOException - If reading or writing failed.
Since:
1.5.8

copyContents

public static void copyContents(java.io.InputStream in,
                                java.io.OutputStream out)
                         throws java.io.IOException
Just copies all bytes from in to out. The copying is performed using a buffer of bytes.

Parameters:
in - The inputstream to copy from
out - The outputstream to copy to
Throws:
java.io.IOException - In case reading or writing fails.
Since:
1.9.31

readContents

public static java.lang.String readContents(java.io.InputStream input,
                                            java.lang.String encoding)
                                     throws java.io.IOException
Reads in file contents.

Parameters:
input - The InputStream to read from.
encoding - The encoding to assume at first.
Returns:
A String, interpreted in the "encoding", or, if it fails, in Latin1.
Throws:
java.io.IOException - If the stream cannot be read or the stream cannot be decoded.

findProperties

public static java.util.Properties findProperties(java.lang.String[] propertyPaths)
                                           throws java.io.IOException
Takes a list of paths and attempts to locate a property file from the list. The first one which can be loaded is parsed and returned.

Parameters:
propertyPaths -
Returns:
Throws:
java.io.IOException - If the reading failed.