So I've been having problems trying to collect all the file names inside a specific folder and storing them in an array[] or as commented, a list.
Here's the code so far:
String[] alist = new String[];
Files.list(Paths.get("mypath")).filter(Files::isRegularFile).forEach(System.out::println(alist);
OR
String[] alist;
alist = Files.list(Paths.get("mypath")).filter(Files::isRegularFile).toArray(String[]::new);
OR
Stream<String> alist = Stream.of(Files.list(Paths.get("path")).filter(Files::isRegularFile).toString());
String[] alist2 = alist.toArray(size -> new String[size]);
As you can see, I'm have a little trouble figuring out the correct method of doing this.
The purpose being once I've got all the file names stored in an array. I can then split each string in the array. To then create a hashmap [key][name] built from the split strings in the array.
I'm just getting back into java and OOP afters years, so I'm a little rusty.
Thanks for any help!