Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Get Files from a directory

private List<File> getFilesFromDirectory(String dir) {
List<File> files = Lists.newArrayList();
Path dirPath = Paths.get(dir);
DirectoryStream<Path> dirFiles = null;
try {
dirFiles = Files.newDirectoryStream(dirPath, glob);
for (Path dirFile : dirFiles) {
files.add(dirFile.toFile());
}
}
catch (Exception cause) {
System.out.println("Exception Occurred, What the hell are you doing");
}

return files;
}

   Like      Feedback     



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner