Hey Everyone, I'm hoping that one of you can help me with a problem I'm having. The code I'm trying to run is compiling fine, but I'm getting a NullPointerException error when I'm actually trying to run it. What I think is happening is the stack is for some reason being initialized with a null value at the beginning.
Any help would be greatly appreciated. Heres the code
[ February 21, 2008: Message edited by: Jack O'Herrer ] [ February 21, 2008: Message edited by: Jack O'Herrer ]
I haven't read through all your code, but you do have a problem here. The String you are assigning in your constructor isn't the same as the String you declare as an instance variable. Can you figure out why?
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joined: Feb 21, 2008
Aha! Thanks, I didn't realize that I reinitialized the string variable.
Now that thats fixed, I'm having problems with writing to the output file. Even when I try to hardcode the line
outFile.println("This is a test");
I'm getting nothing in the file P5.txt
Thanks again for the help
Joined: Jan 17, 2006
Try closing your PrintWriter when you are done writing, aside from that just being a good habit to get into, it also automatically calls the flush() method to ensure all the data in the buffer gets written to the output file.