(Simple question) Why I failed to read from an input file?

S

Shawn

Hi,

I believe I fully understand how to do input/output and I have never run
into problems. But I don't know why this time I cannot make it work. It
is very simple: a text file called "d_array.txt", located in the SAME
folder. But the error says "The system cannot find the file specified".

try
{
BufferedReader inputStream = new BufferedReader(new
FileReader("d_array.txt"));
String line = null;
line = inputStream.readLine().trim();
while ( line != null )
{
this.D.add(Double.valueOf(line));
line = inputStream.readLine().trim();
}
inputStream.close();
}
catch block



I have played the path to the file like following, neither worked:

new FileReader("./d_array.txt");
new FileReader("D:/programming/d_array.txt");
new FileReader("D:\\programming\\d_array.txt");

Thank you for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top