com.vaadin.flow.server.frontend.
Class FileIOUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compareIgnoringIndentationAndEOL
(String content1, String content2, BiPredicate<String, String> compareFn) Compare two file content strings ignoring indentation and EOL characters.
static boolean
compareIgnoringIndentationEOLAndWhiteSpace
(String content1, String content2, BiPredicate<String, String> compareFn) Compare two file content strings ignoring indentation, EOL characters and white space where it does not matter (before and after {, }, ' and : chars).
getFilesByPattern
(Path baseDir, String pattern) Get a list of files in a given directory that match a given glob pattern.
static File
Try determining the project folder from the classpath.
static boolean
isProbablyTemporaryFile
(File file) Checks if the given file is likely a temporary file created by an editor.
static boolean
writeIfChanged
(File file, String content) Writes the given content into the given file unless the file already contains that content.
static boolean
writeIfChanged
(File file, List<String> content) Writes the given content into the given file unless the file already contains that content.
-
Method Details
-
writeIfChanged
Writes the given content into the given file unless the file already contains that content.
Parameters:
file
- the file to write tocontent
- the lines to writeReturns:
true if the content was written to the file, false otherwise
Throws:
IOException
- if something went wrong -
writeIfChanged
Writes the given content into the given file unless the file already contains that content.
Parameters:
file
- the file to write tocontent
- the content to writeReturns:
true if the content was written to the file, false otherwise
Throws:
IOException
- if something went wrong -
getProjectFolderFromClasspath
Try determining the project folder from the classpath.
Returns:
A file referring to the project folder or null if the folder could not be determined
-
isProbablyTemporaryFile
Checks if the given file is likely a temporary file created by an editor.
Parameters:
file
- the file to checkReturns:
true if the file is likely a temporary file, false otherwise
-
getFilesByPattern
Get a list of files in a given directory that match a given glob pattern.
Parameters:
baseDir
- a directory to walk inpattern
- glob pattern to filter files, e.g. "*.js".Returns:
a list of files matching a given pattern
Throws:
IOException
- if an I/O error is thrown while walking through the tree in base directory -
compareIgnoringIndentationAndEOL
public static boolean compareIgnoringIndentationAndEOL(String content1, String content2, BiPredicate<String, String> compareFn) Compare two file content strings ignoring indentation and EOL characters.
Parameters:
content1
- the first file content to comparecontent2
- the second file content to comparecompareFn
- a function to compare the normalized stringsReturns:
true if the normalized strings are equal, false otherwise
-
compareIgnoringIndentationEOLAndWhiteSpace
public static boolean compareIgnoringIndentationEOLAndWhiteSpace(String content1, String content2, BiPredicate<String, String> compareFn) Compare two file content strings ignoring indentation, EOL characters and white space where it does not matter (before and after {, }, ' and : chars).
Parameters:
content1
- the first file content to comparecontent2
- the second file content to comparecompareFn
- a function to compare the normalized stringsReturns:
true if the normalized strings are equal, false otherwise
-