0

I am little bit new in java. I have java source in workspace /src.I created a directory /data in the same project.It means /project/src and /project/data are two directory. I would like to put same directory rather than long absolute path. How would i do it?

BufferedReader buffR1 = new BufferedReader(new FileReader(new File("../data/rural.train.txt")));   

I did like this. But this is not working. I am finding file not found exception.

4

2 回答 2

1

创建运行配置后,对其进行编辑,然后在参数下,将当前目录设置为您的数据文件夹。那么你甚至不需要..在你的路径开始。

于 2012-04-19T08:14:32.797 回答
0

两个选择:

  1. 使路径成为程序中传递的参数
  2. 在您的类路径中添加 /data 目录,然后您不再需要指定路径。
于 2012-04-19T08:18:16.240 回答