I was trying to read a file in java. However my code has a problem and I received errors. It was because I used a relative path to access file. However the following link helped me to resolve the problem.

http://bugs.java.com/bugdatabase/view_bug.do;:YfiG?bug_id=4483097

The part that helped me was:

EVALUATION

Not a bug.  If you need to resolve a filename against the value of
the "user.dir" system property then you must use getAbsolutePath (or
getAbsoluteFile, or getCanonicalPath, or getCanonicalFile).  Simpler
operations such as exists() always resolve against the directory in
which the Java virtual machine was originally invoked (and no, there
is no way to change that).

-- mr@eng 2001/7/23