Reading File Problem
in
Programming Questions
•
3 years ago
Hi everyone,
I have got this simple piece of code:
error
text.txt is in the data folder but I get the same error if I move it to the project root folder,
Why does it happen this?
How can I fix?
Thank you in advance.
I have got this simple piece of code:
- import java.io.*;
- void setup(){
- try{
- BufferedReader fread = new BufferedReader(new FileReader("text.txt"));
- String c;
- String s = null;
- do{
- c = fread.readLine();
- if (c != null){
- System.out.println(c);
- s = c;
- }
- }while(c != null);
- System.out.println("\n"+s);
- fread.close();
- } catch (IOException e){
- System.err.println(e);
- }
- }
java.io.FileNotFoundException: text.txt (Impossibile trovare il file specificato)
error
text.txt is in the data folder but I get the same error if I move it to the project root folder,
Why does it happen this?
How can I fix?
Thank you in advance.
1
