the incoming pattern
and format
, given they are both lower cased, how can I change the below snippet of code so that the startsWith
and endsWith
return true
if the pattern and format are matched case insensitive?
try (Stream<Path> paths = Files.find(cobDir, 1,
(path, attrs) -> attrs.isRegularFile()
&& path.getFileName().startsWith(pattern)
&& path.toString().endsWith(format))) {
matchingFile = paths.findFirst();
} catch (IOException e) {
logger.error("Problem with getting files to process {}", e.getMessage());
}
Is there a prettier way of doing this than the below:
try (Stream<Path> paths = Files.find(cobDir, 1,
(path, attrs) -> attrs.isRegularFile()
&& path.getFileName().toString().toLowerCase().startsWith(pattern)
&& path.toString().toLowerCase().endsWith(format))) {
matchingFile = paths.findFirst();
} catch (IOException e) {
logger.error("Problem with getting files to process {}", e.getMessage());
}