Either I'm not grokking streams like I think I do or my cat snuck a stupid pill into breakfast. I'm trying to read a directory and put all .rle files into a List of some sort, doesn't matter what. I can print the files just fine, but I can't seem to make a list out of them:
Sorry for the formatting, cut and paste isn't working (points towards the cat sneaking me a stupid pill).
Code:
// make a list of all .rle files and put them in a combobox.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class GetRLEFiles {
private void figgurItOut() {
String root = "./patterns";
List<String> patterns;
boolean works = false;
try {
if(works) {
Files.find(Paths.get(root), 999, (p, file) ->
file.isRegularFile()
&& p.getFileName().toString().matches(".*\\.rle"))
.forEach(System.out::println);
}
else {
//patterns = Files.find(Paths.get(root), 999, (p, file) ->
// file.isRegularFile()
// && p.getFileName().toString().matches(".*\\.rle"));
//.toArray();
//.toList();
}
} catch(IOException e) {
System.err.println("IO error: " + e);
}
}
public static void main(String[] args) {
GetRLEFiles g = new GetRLEFiles();
g.figgurItOut();
}
}