net.sourceforge.pmd.util
Class FileUtil

java.lang.Object
  extended by net.sourceforge.pmd.util.FileUtil

public final class FileUtil
extends java.lang.Object

This is a utility class for working with Files.


Method Summary
static java.util.List<DataSource> collectFiles(java.lang.String fileLocations, java.io.FilenameFilter filenameFilter)
          Collects a list of DataSources using a comma separated list of input file locations to process.
static boolean findPatternInFile(java.io.File file, java.lang.String pattern)
          Handy method to find a certain pattern into a file.
static java.lang.String getFileNameWithoutExtension(java.lang.String fileName)
          Helper method to get a filename without its extension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFileNameWithoutExtension

public static java.lang.String getFileNameWithoutExtension(java.lang.String fileName)
Helper method to get a filename without its extension

Parameters:
fileName - String
Returns:
String

collectFiles

public static java.util.List<DataSource> collectFiles(java.lang.String fileLocations,
                                                      java.io.FilenameFilter filenameFilter)
Collects a list of DataSources using a comma separated list of input file locations to process. If a file location is a directory, the directory hierarchy will be traversed to look for files. If a file location is a ZIP or Jar the archive will be scanned looking for files. If a file location is a file, it will be used. For each located file, a FilenameFilter is used to decide whether to return a DataSource.

Parameters:
fileLocations - A comma-separated list of file locations.
filenameFilter - The FilenameFilter to apply to files.
Returns:
A list of DataSources, one for each file collected.

findPatternInFile

public static boolean findPatternInFile(java.io.File file,
                                        java.lang.String pattern)
Handy method to find a certain pattern into a file. While this method lives in the FileUtils, it was designed with with unit test in mind (to check result redirected into a file)

Parameters:
file -
pattern -
Returns:


Copyright © 2002-2015 InfoEther. All Rights Reserved.