I am building a library for which the user already has code that processes an array of Paths. I have this:
Collection<File> filesT = FileUtils.listFiles(
new File(dir), new RegexFileFilter(".txt$"),
DirectoryFileFilter.DIRECTORY
);
I use the List of File object throughout but needed a way to convert filesT to List<Path>. Is there a quick way, maybe lambda to quickly convert one list to the other?
If you have a
Collection<File>
, you can convert it toList<Path>
or toPath[]
usingFile::toPath
method reference: