Answers for "how to read current directory in java"

2

how to get current directory in java

public class JavaApplication {
  public static void main(String[] args) {
    System.out.println("Working Directory = " + System.getProperty("user.dir"));
  }
}
Posted by: Guest on March-30-2021
0

java read directory

public void listFilesForFolder(final File folder) {
    for (final File fileEntry : folder.listFiles()) {
        if (fileEntry.isDirectory()) {
            listFilesForFolder(fileEntry);
        } else {
            System.out.println(fileEntry.getName());
        }
    }
}

final File folder = new File("/home/you/Desktop");
listFilesForFolder(folder);
Posted by: Guest on August-10-2021

Code answers related to "how to read current directory in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language