Created
July 23, 2016 08:21
-
-
Save carlosdlf/ab5c7f9dad0d2cbc106c5d5d3ca61c17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.DirectoryStream; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
public static List<String> fileList(String directory) { | |
List<String> fileNames = new ArrayList<>(); | |
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(directory))) { | |
for (Path path : directoryStream) { | |
fileNames.add(path.toString()); | |
} | |
} catch (IOException ex) {} | |
return fileNames; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment