[java] Console input

Started by
2 comments, last by GKW 23 years, 6 months ago
Why does this work public class someclass { InputStreamReader isr; BufferedReader br; public someclass() { isr = new InputStreamReader( System.in ); br = new BufferedReader( isr ); } public getinput() { get input for console } } and I get a NullPointerException with this in getinput() with respect to the BufferedReader? public class someclass { InputStreamReader isr; BufferedReader br; public someclass() { setupIO(); } public void setupIO() { isr = new InputStreamReader( System.in ); br = new BufferedReader( isr ); } public getinput() { get input for console } } btw new beta of Forte For Java out for those who don''t know. I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson
Advertisement
I was able to use either method and access br in the getinput method.

Is it possible you have BufferedReader br = new BufferedReader(isr) in your second situation...if so, you need to remove the BufferedReader from in front of br.

Hope this helps
God damn it, you are right. But can you figure out why last night the program would find another class in the same package and today it can''t find it. Compiles in the command line but not in the IDE. Same paths and all. I will try and pull my head out of my ass before I post again. Thanks.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson
Would need some more info on your second problem but I would guess it is related to classpaths (but it looks like you were checking those).

This topic is closed to new replies.

Advertisement