Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualShippou

Posted 11 December 2012 - 12:09 AM

I am getting very frustrated with this. This is literally "text book" on how I am to iterate threw a text file - YET it throws a NULL POINTER error when it reaches the end of the file - which it shouldn't do.

Some_File.file
STONE|99
GRASS|2
SAND|67
Code
try{
	FileInputStream fstream = new FileInputStream("Some_File.file");
	DataInputStream is = new DataInputStream(fstream);
	BufferedReader br = new BufferedReader(new InputStreamReader(is));
	String Line;
	while ( ( Line = br.readLine() ) != null )	{ // This throws NULL POINTER after done with file
	String[] Temp = Line.split("\\|");
	System.out.println(Temp[0].trim() + " " + Temp[1].trim() + " " + Line);
    }
}

#1Shippou

Posted 11 December 2012 - 12:05 AM

I am getting very frustrated with this. This is literally "text book" on how I am to iterate threw a text file - YET it throws a NULL POINTER error when it reaches the end of the file - which it shouldn't do.

Some_File.file
STONE|99
GRASS|2
SAND|67
Code
try{
    FileInputStream fstream = new FileInputStream("Some_File.file");
    DataInputStream is = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String Line;
    while ( ( Line = br.readLine() ) != null )    { // This throws NULL POINTER after done with file
    String[] Temp = Line.split("\\|");
    System.out.println(Temp[0].trim() + " " + Temp[1].trim() + " " + Line);
}

PARTNERS