Note that there are some explanatory texts on larger screens.

plurals
  1. POFile not found exception that does not make sense (For me)
    text
    copied!<p>I have a program that reads and writes from a file. <strong>I EVEN tried to create the file in <code>main</code></strong> but it still doesn't work. </p> <pre><code>public static void main(String[] args) throws NumberFormatException, IOException, FileNotFoundException { System.out.println("Work in progress"); File f = new File("Data.txt"); System.out.println(f.getAbsolutePath()); // Yes, it's there. UI ui = new UI(); GenericDictionary&lt;Integer&gt; gd = new GenericDictionary&lt;Integer&gt;(); Repository repo = new Repository("Data.txt", gd); // Should work, right ? </code></pre> <p>Now my Repository:</p> <pre><code>public Repository (String fileName, GenericDictionary gd) throws IOException, NumberFormatException, FileNotFoundException { this.fileName = fileName; this.gd = gd; FileReader input = null; BufferedReader inputBuffer = null; try { input = new FileReader(this.fileName); inputBuffer = new BufferedReader (input); String line; while ((line = inputBuffer.readLine()) != null) { String[] inputData = line.split(","); Node&lt;Integer&gt; newNode = new Node&lt;Integer&gt; ( Integer.parseInt(inputData[0]), Integer.parseInt(inputData[1])); this.gd.add(newNode); } }catch (NumberFormatException nfe){ System.out.println( "Repository could not load data due to NumberFormatException: " + nfe); }catch (FileNotFoundException fnfe) { System.out.println("File not found, error: " + fnfe); }finally { inputBuffer.close(); input.close(); } } </code></pre> <p>Now even though I create my file it does not want to use it. Initially it was in the constructor of my repository, I moved it into the main file, still no success.</p> <p><strong>This is what Eclipse prints within console:</strong></p> <ul> <li>Work in progress D:\Info\Java workspace\Laborator_4\Data.txt File not found, error: java.io.FileNotFoundException: Data.txt (The system cannot find the file specified) Exception in thread "main" java.lang.NullPointerException at repository.Repository.(Repository.java:49) at main.app.main(app.java:23)</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload