net.sourceforge.pmd.util
Class FileUtil

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

public final class FileUtil
extends Object

This is a utility class for working with Files.


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

Method Detail

getFileNameWithoutExtension

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

Parameters:
fileName - String
Returns:
String

normalizeFilename

public static String normalizeFilename(String fileName)
Normalizes the filename by taking the casing into account, e.g. on Windows, the filename is changed to lowercase only.

Parameters:
fileName - the file name
Returns:
the normalized file name

collectFiles

public static List<DataSource> collectFiles(String fileLocations,
                                            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(File file,
                                        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-2016 InfoEther. All Rights Reserved.