0

Hi I want to read a line from a .txt file using the Bufferd reader everything works perfect and I get my result but in the same time I get a Nullpointer exception at the end.

I want to reed this line from a .txt : 4 4;3 5 4 8 ;3 5 21,3 4 17,4 5 13,8 3 29,

public static void DateiLeser(){   
        BufferedReader br = null;
        try {

            br = new BufferedReader(new FileReader(new File("dat.txt")));
            String line = null;


while(!((line = br.readLine()).isEmpty())) {     //<-Nullpointer
                //reading tasks
            }
        } catch(FileNotFoundException e) {
            e.printStackTrace();
        } catch(IOException e) {
            e.printStackTrace();

        } 
        catch(ArrayIndexOutOfBoundsException e) {

            e.printStackTrace();

        }

        finally {
            if(br != null) {
                try {
                    br.close();
                } catch(IOException e) {
                    e.printStackTrace();

                }
            }
        }

    }
noxus Nexus
  • 83
  • 1
  • 5

0 Answers0