[File]Reading a file
I am puzzled as the prog does not fin the file ; this is the code :
JFileChooser chooser = new
JFileChooser("/media/USER_data/dmoyne_data/GENEALOGIE_data/GenJ_data/GenJ_data/actes/Menotey/tmp");
int FileSelectorIntValue = chooser.showOpenDialog(null);
if(FileSelectorIntValue == JFileChooser.APPROVE_OPTION) {
String FileNameStringValue=chooser.getSelectedFile().getName();
println("You chose to open this file: "+FileNameStringValue);
BufferedReader entree=new BufferedReader(new
FileReader(FileNameStringValue));
String ligne;
do {
ligne=entree.readLine();
if (ligne != null) {
println("ligne :"+ligne);
}
} while (ligne != null) ;
entree.close();
println("fin lecture fichier");
}
else {
println("You have not selected a file : abortion");
}
Once I have selected my text file with the File Selector I get this error
message :
java.lang.RuntimeException: report failed
at genj.report.Report.start(Report.java:940)
at genj.report.ReportView$ActionStart.execute(ReportView.java:450)
at genj.util.swing.Action2$CallAsyncExecute.run(Action2.java:487)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.FileNotFoundException: batch.txt (No such file or
directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at java.io.FileReader.<init>(FileReader.java:41)
at ReportPluginBatchEntry.start(ReportPluginBatchEntry.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at genj.report.Report.start(Report.java:931)
... 3 more
Basically that my "batch.txt" file as selected with the File Selector cannot
be found.
Is this a path problem because the FileNameStringValue as returned by the
filer is simply the file name ; if I have to concatenate the path how do I
get it from the File selector to do :
FileNameStringValue=FilePathStringValue+FileNameStringValue;
Regards.