I'm writing a class that extracts the contents of a zip file that is in the current working directory. However it only works if I know the filename. What is the best way to grab the names of files that just end in .zip into a String array so I can have my program unzip the files listed only in the array? Much thanks for suggestions.
Asked
Active
Viewed 80 times
1 Answers
0
Arrays.stream(new File("./").listFiles()).filter(f -> f.getName().endsWith(".zip")).forEach(f -> {
do something
});
In Java8, you can use filter

chengpohi
- 14,064
- 1
- 24
- 42