Answers for "get files in path java"

2

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());
    }
}
Posted by: Guest on June-12-2020
3

get file path java

File file = new File("yourfileName");
String path = file.getAbsolutePath();
Posted by: Guest on February-24-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language