com.zmicer.utils
Class FileUtils

java.lang.Object
  extended by com.zmicer.utils.FileUtils

public class FileUtils
extends Object

This utility class is used for all the file related operations.

$Author:: zmicer $
$Rev:: 57 $
* $Date:: 2007-08-23 09:16:37 #$


Field Summary
static org.apache.log4j.Logger LOG
          Logger instance.
 
Constructor Summary
FileUtils()
           
 
Method Summary
static String constructPath(String... args)
          Construct the full path using the provide variable args.
static List<File> findFilesByRE(File dirFile, Pattern reFileDefinition)
          Find files by regular expression provided.
static List<File> findFilesByRE(String dirName, Pattern reFileDefinition)
          Accumulate all the files by the provided Regular Expression Patterns.
static List<File> findFilesByREInClassPath(List<String> classPathStrings, Pattern reFileDefinition)
          Find the files using the provided regular expression (e.g
static List<File> findFoldersByRE(File dirFile, Pattern reFolderDefinition)
          Find files by regular expression provided.
static List<File> findFoldersByRE(String dirName, Pattern reFolderDefinition)
          Accumulate all the files by the provided Regular Expression Patterns.
static String getFolderBaseName(String folderFullName)
          Get the folder name inself using the provided full or relative folder name
static ResourceBundle getResourceBundleViaFile(String resourceName)
          Get the resource bundle using the File class facilities (inside the method the PropertyResourceBundle is used).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Logger instance.

Constructor Detail

FileUtils

public FileUtils()
Method Detail

findFilesByRE

public static List<File> findFilesByRE(String dirName,
                                       Pattern reFileDefinition)
Accumulate all the files by the provided Regular Expression Patterns. All the dirs are searched reqursively

Parameters:
dirName - the dir name.
reFileDefinition - Pattern for the regular expression to find all the files
Returns:
the List of File objects with the valid values

findFilesByRE

public static List<File> findFilesByRE(File dirFile,
                                       Pattern reFileDefinition)
Find files by regular expression provided. Accumulate all the files by the provided Regular Expression Patterns. All the dirs are searched reqursively

Parameters:
dirFile - dir file where we would find the file defined by Regular Expression Can not be null (otherwise IllegalArgumentException would appear). It should be the valid directory, otherwise IllegalArgumentException would appear
reFileDefinition - regular expression for the file name Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of File objects found using the provided search criteria, or null in another case

findFoldersByRE

public static List<File> findFoldersByRE(String dirName,
                                         Pattern reFolderDefinition)
Accumulate all the files by the provided Regular Expression Patterns. All the dirs are searched reqursively

Parameters:
dirName - the dir name.
reFolderDefinition - Pattern for the regular expression to find all the files
Returns:
the List of File objects with the valid values

findFoldersByRE

public static List<File> findFoldersByRE(File dirFile,
                                         Pattern reFolderDefinition)
Find files by regular expression provided. Accumulate all the files by the provided Regular Expression Patterns. All the dirs are searched reqursively

Parameters:
dirFile - dir file where we would find the file defined by Regular Expression Can not be null (otherwise IllegalArgumentException would appear). It should be the valid directory, otherwise IllegalArgumentException would appear
reFolderDefinition - pattern object for the name of the folder we are looking for Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of File objects found using the provided search criteria, or empty List in another case

findFilesByREInClassPath

public static List<File> findFilesByREInClassPath(List<String> classPathStrings,
                                                  Pattern reFileDefinition)
Find the files using the provided regular expression (e.g. ".*jpatterns.*(?ClassPathUtils.getClassPathes() for details).
The class path entities allow us to use this method not only for the class path but with other pathes, dirs etc.

Parameters:
classPathStrings - the List of String objects, Can not be null (otherwise IllegalArgumentException would appear).
reFileDefinition - the Pattern compliled before, Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of the valid File object (file.isFile would be return true)

getFolderBaseName

public static String getFolderBaseName(String folderFullName)
Get the folder name inself using the provided full or relative folder name

Parameters:
folderFullName - the folder name we should analyze, Can not be null (otherwise IllegalArgumentException would appear).
Returns:
String, folder base name

getResourceBundleViaFile

public static ResourceBundle getResourceBundleViaFile(String resourceName)
Get the resource bundle using the File class facilities (inside the method the PropertyResourceBundle is used).

Parameters:
resourceName - the name of the resource, Can not be null (otherwise IllegalArgumentException would appear). Be noticed it could take the following types of values: 1. the full or relative path to the resource using the File.separator 2. the relative path to the resource where the dot (".") is used as the separator.
note [zmicer]: it could contains ".properties" or could not.
Returns:
the resource bundle we are looking for or null in the case there is no appropriate resource bundle or it has wrong format, or smth else went in the wrong way.

constructPath

public static String constructPath(String... args)
Construct the full path using the provide variable args.

Parameters:
args - the variable args, Can not be null (otherwise IllegalArgumentException would appear). The members of this cannot be null.
Returns:
the full path. The File.separator is used for the constructing the path


Copyright © 2007 jzmicer.team. All Rights Reserved.