I've got some problems trying to print available directories on the screen.
Here's some code with two possible ways to print it:
File f = new File(System.getProperty("user.home"));
System.out.println(java.util.Arrays.toString(f.list())); //the FIRST way
for (String fileName : f.list()) { //the SECOND
System.out.println(fileName); // way
}
Looks like it's a pretty good way to print directories but it prints more directories than really exist.
Thus I have to 2 questions: How to print it correctly? How to print it correctly but from another directory, not from "user.home"?
UPD!!! Ok guys, I've just found out that the problem is that it shows even hidden directories. So now please help me to print not hidden directories only.
but it prints more directories than really existsure?How to print it correctly but from another directory... provide a different directory innew File("/path/blub").