Daniel Moyne wrote On 01/09/07 10:57,:
> I am puzzled as the prog does not fin the file ; this is the code :
>
[quoted text clipped - 7 lines]
> FileReader(FileNameStringValue));
> [...]
Use getPath() or getAbsolutePath() instead of getName().
getName() returns only the name of the file, without any of
the directory specifications:
File f = new File("/a/b/c/d/foo.txt");
String s = f.getName(); // yields just "foo.txt"

Signature
Eric.Sosman@sun.com
Eric Sosman - 09 Jan 2007 17:39 GMT
Eric Sosman wrote On 01/09/07 11:30,:
> Daniel Moyne wrote On 01/09/07 10:57,:
>
[quoted text clipped - 16 lines]
> File f = new File("/a/b/c/d/foo.txt");
> String s = f.getName(); // yields just "foo.txt"
There's an even better way that I completely overlooked
(I'm having a stupidity attack today): Instead of fooling
around with strings, just use the File object the chooser
gave you:
File chosenFile = chooser.getSelectedFile();
...
BufferedReader ... (new FileReader(chosenFile));

Signature
Eric.Sosman@sun.com
Daniel Moyne - 09 Jan 2007 23:33 GMT
> Eric Sosman wrote On 01/09/07 11:30,:
>> Daniel Moyne wrote On 01/09/07 10:57,:
[quoted text clipped - 26 lines]
> ...
> BufferedReader ... (new FileReader(chosenFile));
Thanks Eric,
this was the way to go ; I started from an example where the file was
supposed to be located in th current directory which with a File Selector
has no real use !
Thanks again.
Daniel.