Skip to content

Instantly share code, notes, and snippets.

@kevinrobayna
Created June 23, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinrobayna/9ddd36f61183dca055d2 to your computer and use it in GitHub Desktop.
Save kevinrobayna/9ddd36f61183dca055d2 to your computer and use it in GitHub Desktop.
File folder = new File("your/path");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("File " + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("Directory " + listOfFiles[i].getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment