Hi 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.
"The SAME folder" as what?
The class-files? Note that the location of the class-files does not have
anything to do with the 'current directory' (".") which you probably
mean. (*)
> new FileReader("d_array.txt"));
> new FileReader("./d_array.txt");
> new FileReader("D:/programming/d_array.txt");
> new FileReader("D:\\programming\\d_array.txt");
This should all work, if "D:/programming/" is your current directory.
Your error must be elsewhere!
Ciao,
Ingo
(*) Note that there are methods like Class.getResourceAsStream() and
ClassLoader.getResourceAsStream()!
Shawn - 21 Nov 2006 16:16 GMT
> Hi Shawn,
>
[quoted text clipped - 25 lines]
> (*) Note that there are methods like Class.getResourceAsStream() and
> ClassLoader.getResourceAsStream()!
Sorry. I have made it work. Somehow, the Eclipse required me to use the
full path (even though my text input file is located in the same
directory as the java file). So
>> new FileReader("D:\\programming\\d_array.txt");
should work. It didn't before, because of something else.
Thank you for your help.
Ingo R. Homann - 22 Nov 2006 09:38 GMT
Hi,
> Somehow, the Eclipse required me to use the
> full path (even though my text input file is located in the same
> directory as the java file).
Note that the location of the source-files is not available at runtime!
Ciao,
Ingo
> Hi,
>
[quoted text clipped - 23 lines]
> new FileReader("D:/programming/d_array.txt");
> new FileReader("D:\\programming\\d_array.txt");
Are you sure your d_array.txt file is located in your D:\programming
directory?
- Oliver
Shawn - 21 Nov 2006 16:26 GMT
>> I have played the path to the file like following, neither worked:
>>
[quoted text clipped - 6 lines]
>
> - Oliver
Thank you. Yes, I have replied previously. That,
>> new FileReader("D:\\programming\\d_array.txt");
should have worked. It failed due to some other error.