If you want to list only the directories in Java, you can use the following code:
File dir = new File("/My/Directory/Path"); File[] directories = dir.listFiles((FilenameFilter) DirectoryFileFilter.INSTANCE); for (int i = 0; i < directories.length; i++) { // Each file is a directory directories[i].getAbsolutePath(); }
No comments:
Post a Comment