net.sf.doolin.util
Class IOUtils

java.lang.Object
  extended by net.sf.doolin.util.IOUtils

public class IOUtils
extends Object

Some I/O utility methods

Author:
Damien Coraboeuf

Method Summary
static Collection<File> listFiles(File root, FileFilter filter, boolean recursive)
          Collects a list of files, according to a given pattern, from a root directory and recursively.
static Properties readProperties(String respath)
          Read a property file from resources
static String readTextResource(Class<?> referenceClass, String path, String encoding)
          Reads a text resource from a reference class and a resource path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readProperties

public static Properties readProperties(String respath)
Read a property file from resources

Parameters:
respath - Resource to be read
Returns:
Properties

listFiles

public static Collection<File> listFiles(File root,
                                         FileFilter filter,
                                         boolean recursive)
Collects a list of files, according to a given pattern, from a root directory and recursively.

Parameters:
root - Directory to start from
filter - File filter to use
recursive - Indicates if the search must be recursive or not.
Returns:
List of found files, not null.

readTextResource

public static String readTextResource(Class<?> referenceClass,
                                      String path,
                                      String encoding)
                               throws net.sf.jstring.LocalizableException
Reads a text resource from a reference class and a resource path. The resource URL is determined by computing the resource path from the reference class. If the reference class is null, the path is computed using the current class (i.e. the IOUtils class). If the resource cannot be accessed, a CodeException with code StringCodes.STRING_ERROR_RESOURCE_NOT_FOUND is thrown.

Parameters:
referenceClass - Reference for the resource path
path - Resource path from the reference class
encoding - Encoding of the target resource
Returns:
Resource content
Throws:
net.sf.jstring.LocalizableException - If the resource cannot be found


Copyright © 2011. All Rights Reserved.