Package de.tsl2.nano.util
Class FilePath
java.lang.Object
de.tsl2.nano.util.FilePath
provides actions on a path and all its subdirectories and files.
all use the base function
recurse(String, String, String, Function)- Author:
- Thomas Schneider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcopies all files in a given directory to the given targetstatic intdeleteDirectory(String dir) deletes all files in a given directorystatic <RESULT> Collection<RESULT>foreach(String dir, String includes, String excludes, String contentRegEx, Function<Path, RESULT> fct) static BufferedWritergetFileWriter(String file) static intmoves all files in a given directory to the given targetstatic byte[]static <R> intas Paths.get(file).foreach(consumer) walks only the path elements itself from root, this walks through all recursive files/paths starting on given dir.static Path
-
Constructor Details
-
FilePath
public FilePath()
-
-
Method Details
-
deleteDirectory
deletes all files in a given directory -
copy
copies all files in a given directory to the given target -
move
moves all files in a given directory to the given target -
foreach
public static <RESULT> Collection<RESULT> foreach(String dir, String includes, String excludes, String contentRegEx, Function<Path, RESULT> fct) - Type Parameters:
RESULT- function result type, to be collected as return value- Parameters:
dir- base directory to start onincludes- optional file name include regular expressionexcludes- optional file name exclude regular expressioncontentRegEx- regular expression to be matched inside the files contentfct- action to do if file name and content matches- Returns:
- all results of all function calls
-
recurse
public static <R> int recurse(String dir, String includes, String excludes, Function<Path, R> action) as Paths.get(file).foreach(consumer) walks only the path elements itself from root, this walks through all recursive files/paths starting on given dir.- Parameters:
dir- base directory to start onincludes- optional file name include regular expressionexcludes- optional file name exclude regular expressionaction- if file name matches, this function will be executed. if the function returns a value != null, the result count will be increased.- Returns:
- count of function calls with result != null
-
read
-
write
-
getFileWriter
-