I am developing a program where I read a file whose content is the name of other files that I need to read their content.
I do it and store every line (which represents a file name) in a list of strings.
Then I create a method whose purpose it is print on screen the content of every file, line by line. Here the problem shows up. It starts to execute and then it says that the file whose name is stored in the list of strings cannot be found! Here is the output:
And here is the code of the method./java -classpath Procurador\ de\ Texto/ Main nomesArquivos.txt
File1.txt
File2.txt
File3.txt
Exception in thread "main" java.io.FileNotFoundException: File1.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.jav a:138)
at java.io.FileInputStream.<init>(FileInputStream.jav a:97)
at java.io.FileReader.<init>(FileReader.java:58)
at FileManager.readFile(FileManager.java:22)
at Main.main(Main.java:9)public void readFile () throws Exception { for (int i=0; i<configFiles.size(); i++) { FileReader fr = new FileReader (configFiles.get(i)); BufferedReader br = new BufferedReader (fr); while ((line = br.readLine()) != null); { System.out.println (line); //System.out.println ("Boto"); } fr.close(); } }
I know that the name of the files stored in the list (configFiles) are the correct names because I printed them in the screen and they are correct (As can be seen in the beginning of the quote)
The name of the files itself are also correct.
So what can be the problem?
Thanks for any help.