Filter all files with a particular extension in Java
How can i filter files with particular extension in Java, let say i want to filter all .json files from a folder.
1 Answer
7 years ago by Divya
Following code filters all json files from the flder /path/to/folder
Arrays.asList(Paths.get("/path/to/folder").toFile().listFiles(file -> !file.isHidden() && file.isFile() && (file.getName().endsWith(".json")))).forEach(file -> {
// deal with the file
});
7 years ago by Karthik Divi