Results 1 to 6 of 6
Thread: Null pointer exception
- 03-31-2009, 04:10 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Null pointer exception
Hi all,
I'm confused with the runtime NullPointerException occured at the arrow line of the following code segment.
BufferedReader in;
String line;
StringBuffer sb = new StringBuffer();
sb=null;
byte[] result;
try {
FileReader fileReader = new FileReader(this.filename);
System.out.println("filename is "+this.filename);
in = new BufferedReader(fileReader);
do{line=in.readLine();
if (line != null){
--> sb.append(in.readLine());}
}while (line != null);
String str=new String(sb.toString());
result = mac.doFinal(str.getBytes());
System.out.println(filename+" :"+result);
}
Please help!
-
The compiler never lies:
construct your StringBuilder before using it, and you should have no problems.Java Code:sb=null;
- 03-31-2009, 10:57 AM #3
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
I'm sorry, but ROFL
What did you expect?Java Code:StringBuffer sb = new StringBuffer(); sb=null; ... sb.append(in.readLine());}
- 04-01-2009, 08:52 AM #4
Member
- Join Date
- Apr 2009
- Posts
- 20
- Rep Power
- 0
Comment following line:
sb=null;
- 04-01-2009, 02:12 PM #5
Member
- Join Date
- Apr 2009
- Posts
- 3
- Rep Power
- 0
Hi Folks,
I just joined this Forum ...I am stuck up with a problem related with 2 phase commit in case of Distributed transactions...I have decided to go for JBoss JTA for achieving that..but I am getting two errors XA error -4 and SQL exception 24756...can somebody help me on this ...
- 04-01-2009, 02:17 PM #6
amt asc... it is not considered good taste to post on somebody else's post (it's called hijacking). Please start your own post, make sure you're in the correct sub-forum and list all errors (complete stack dumps) along with associated code.
Luck,
CJSLLast edited by CJSLMAN; 04-01-2009 at 02:26 PM. Reason: typo
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Similar Threads
-
Null pointer Exception
By peiceonly in forum New To JavaReplies: 8Last Post: 09-05-2010, 06:48 PM -
Null Pointer Exception
By andre1011 in forum Advanced JavaReplies: 4Last Post: 02-07-2009, 03:30 AM -
Null Pointer Exception
By ScKaSx in forum New To JavaReplies: 1Last Post: 01-24-2009, 11:27 AM -
Null Pointer Exception
By Jacinth in forum New To JavaReplies: 4Last Post: 01-22-2009, 01:47 PM -
getting a null pointer exception
By Rjava in forum XMLReplies: 4Last Post: 07-16-2008, 05:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks