Skip to content

Instantly share code, notes, and snippets.

@vorobeij
Last active June 7, 2017 09:31
Show Gist options
  • Select an option

  • Save vorobeij/c4896b2ba74dcd2edf0be28608b86bcd to your computer and use it in GitHub Desktop.

Select an option

Save vorobeij/c4896b2ba74dcd2edf0be28608b86bcd to your computer and use it in GitHub Desktop.
get all text files in folder
private static List<File> getFilesInFolder(String path) {
List<File> files = new ArrayList<>();
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
files.add(listOfFiles[i]);
} 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