Get current directory


This example shows how to get the value of the current directory.
It gets the value of a system property called "user.dir";


public class FileUtil {

  public void displayCurrentDir() {

    System.out.println(System.getProperty("user.dir"));
      
  }

  public static void main(String[] args) {
    FileUtil fileutil = new FileUtil();
    fileutil.displayCurrentDir();
  }
}

 





   What kind of Java example would you like to see on this site?

   
     E-mail (optional)