Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to get all the names of the files in a folder in java?

List<String> results = new ArrayList<String>();


File[] files = new File("/path/to/the/directory").listFiles();
//If this pathname does not denote a directory, then listFiles() returns null. 

for (File file : files) {
    if (file.isFile()) {
        results.add(file.getName());
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #names #files #folder
ADD COMMENT
Topic
Name
5+9 =