Class FileUtil
- java.lang.Object
-
- net.sourceforge.pmd.internal.util.FileUtil
-
public final class FileUtil extends Object
This is a utility class for working with Files.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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 extensionstatic String
normalizeFilename(String fileName)
Normalizes the filename by taking the casing into account, e.g.static List<Path>
readFilelistEntries(Path filelist)
Reads the file, which contains the filelist.static @NonNull Path
toExistingPath(String root)
-
-
-
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
-
toExistingPath
public static @NonNull Path toExistingPath(String root) throws FileNotFoundException
- Throws:
FileNotFoundException
-
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:
-
readFilelistEntries
public static List<Path> readFilelistEntries(Path filelist) throws IOException
Reads the file, which contains the filelist. This is used for the command line arguments --filelist/-filelist for both PMD and CPD. The separator in the filelist is a comma and/or newlines.- Parameters:
filelist
- the file which contains the list of path names- Returns:
- a list of file paths
- Throws:
IOException
- if the file couldn't be read
-
-