-3
private void getInput() throws IOException {

    InputStream resourceAsStream = this.getClass().getResourceAsStream(
            "aaa.txt");
    BufferedReader br = new BufferedReader(new FileReader(
            resourceAsStream.toString()));
    try {
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            sb.append(System.lineSeparator());
            line = br.readLine();
        }
        String everything = sb.toString();
        System.out.println(everything);
    } finally {
        br.close();
    }
}

The file aaa.txt is in the same project and it cannot be read, I have java.lang.NullPointerException when I execute that.

Boolena
  • 205
  • 1
  • 2
  • 8

1 Answers1

0

Only do this

BufferedReader br = new BufferedReader(new FileReader("aaa.txt"));

But put the file in the filereader instead.

Hope it helpt.

JeppeSRC
  • 89
  • 8