So, I've been trying to count the total amount of elements in a directory. It always returns 0.
This is my code:
public int getElementsInDirectory() {
Path path = Paths.get(applicationFolder.getAbsolutePath());
Logger.log("Directory", "Absoloute path: " + path);
if(path == null) {
Logger.log("Directory", "Path doesn't exist");
return 0;
}
Paths.get(applicationFolder.getAbsolutePath()).getRoot().forEach(p -> {
elements++;
});
return elements;
}
I've tried several directories where the files are being counted, but well, still returns to 0.
And the best part is, the path is also not null, as this is the output
[2015-07-25, Directory] Created folder!
[2015-07-25, Directory] Absoloute path: C:\Users\Yasin
So it's pretty much finding the path correctly, now it's just the elements.
Oh yeah, almost forgot:
new File(System.getProperty("user.home") + "/");
Is applicationFolder