在学习java的过程中,种是遇到文件路径的问题。因为我们经常需要把程序运行生成的文件保存到当前目录下。而不是放在c ,d E,等盘指定的目录。这样做的目的,主要是考虑到Linux系统并不支持c,d,e盘的标识形式。
所以考虑到程序的可移植性,我们将程序生成的文件保存在当前目录是最恰当的。
1.但前项目运行下的目录
File RunTimePath = new File(".")
File RunTimePath = new File("/")
File RunTimePath = new File("./")
这三者的目录都在:项目名/.
例如利用RunTimePath .getAbsolutePath() 输出结果为C:/Documents and Settings/Manager/jbproject/datatest/.
所以考虑到程序的可移植性,我们将程序生成的文件保存在当前目录是最恰当的。
1.但前项目运行下的目录
File RunTimePath = new File(".")
File RunTimePath = new File("/")
File RunTimePath = new File("./")
这三者的目录都在:项目名/.
例如利用RunTimePath .getAbsolutePath() 输出结果为C:/Documents and Settings/Manager/jbproject/datatest/.