thetna
thetna

Reputation: 7143

Setting source and data path in java

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.

Upvotes: 0

Views: 1465

Answers (2)

Cole
Cole

Reputation: 179

Two chioces:

  1. make the path an argument passed in your programm
  2. add the /data directory in your classpath, then you don't need specify the path anymore.

Upvotes: 0

Marko Topolnik
Marko Topolnik

Reputation: 200148

Once you create a Run Configuration, go edit it and, under Arguments, set te Current directory to your data folder. Then you won't even need the .. at the beginning of your path.

Upvotes: 1

Related Questions