Computer Science Canada HELP!!! I got NULL! |
Author: | nogardreyals [ Sun Jun 14, 2009 2:59 pm ] |
Post subject: | HELP!!! I got NULL! |
void readerwriter () throws java.io.IOException { String input; boolean higher; int number = 0; FileReader fra = new FileReader ("ProjectData.txt"); BufferedReader bfra = new BufferedReader (fra); do { for (int count = 0 ; count < bfra.readLine ().length () ; count++) { if (Character.isDigit (bfra.readLine ().charAt (count)) == true) //basically, im trying to look at my txt file one line at a time, and looking for a number one char at a time { number = (int) bfra.readLine ().charAt (count); } } } while (bfra.readLine () != null); fra.close (); // This is a part of a method i used. I cannot run this part because the bolded segnment gets: java.lang.NullPointerException at GameMethods.readerwriter(GameMethods.java:427) at FinalProjectMain.main(FinalProjectMain.java:18) I do not know why. Can anyone help? |
Author: | McKenzie [ Sun Jun 14, 2009 7:22 pm ] |
Post subject: | RE:HELP!!! I got NULL! |
Each time you bfra.readLine () it reads a new line so your for loop, your if, and your assignment are three different lines. |