2015年10月27日火曜日

現在のディレクトリ(パス)を取得するプログラム(Java)

現在のディレクトリ(パス)を取得するプログラムです。

public class Test1 {
public static void main(String[] args) {
System.out.println(getCurrentDir());
}

public static String getCurrentDir(){
      String path = new File(".").getAbsoluteFile().getParent();
   return path;
}
}