Java – 查看程序的当前目录(路径)
Java中碰到使用相对路径读写文件时(最近碰到一个老是找不到文件的问题),需要查看程序的默认当前路径。网上找了一下,下面的代码可以显示当前的程序默认路径,文件找不到终于解决了~~
// Get base path
File appBase = new File("."); //current directory
String path = appBase.getAbsolutePath();
System.out.println(path);
参考资料:
1、http://answers.yahoo.com/question/index?qid=20080801074923AA3UyN3