Archived

This topic is now archived and is closed to further replies.

GKW

[java] Console input

Recommended Posts

GKW    200
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!

Share this post


Link to post
Share on other sites
latrobe    122
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

Share this post


Link to post
Share on other sites
GKW    200
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!

Share this post


Link to post
Share on other sites
latrobe    122
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).

Share this post


Link to post
Share on other sites