Results 1 to 3 of 3
Thread: Properties: NullPointException
- 11-12-2011, 03:07 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Properties: NullPointException
Hey guys,
I'm trying to assign a String the value of a property key-value pair but I get a NullPointerException when I try to run the code.
The method, part of the HTTPThread class, is:
These properties are initiated in the WebServer class like this:Java Code:187 public void statusline(String version, int codeIn) { 188 189 String code = Integer.toString(codeIn); 190 String reason = WebServer.responsecodes.getProperty(code); 191 192 if(reason == null) { 193 194 code = "500"; 195 reason = "Internal Server Error"; 196 } 197 198 writer.print(version + " " + code + " " + reason + "\r\n"); 199 }
The properties are loaded correctly because I can access them inside the WebServer class.Java Code:44 try { 45 46 responsecodes = new Properties(); 47 responsecodes.load(new FileInputStream("properties"+separator+"responsecodes.properties")); 48 49 } catch(IOException e) { 50 51 // Couldn't read response codes 52 System.out.println("Error: couldn't read response codes"); 53 }
My stack trace (tester just runs HTTPThread):
Java Code:debug: Exception in thread "main" java.lang.NullPointerException at server.HTTPThread.statusline(HTTPThread.java:190) at server.HTTPThread.run(HTTPThread.java:87) at server.tester.main(tester.java:20) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds)
- 11-12-2011, 03:16 PM #2
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Re: Properties: NullPointException
I also get a NullPointerException for other operations that I assumed would work fine, such as:
Why would this be? Is it something to do with how threads handle null values?Java Code:while((header = reader.readLine()) != null) { ... }
- 11-12-2011, 04:57 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
Properties
By Winarto in forum XMLReplies: 0Last Post: 08-29-2008, 03:32 PM -
properties help me please
By Winarto in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-29-2008, 12:42 PM -
Getting .mp3 properties
By Leprechaun in forum New To JavaReplies: 1Last Post: 02-06-2008, 05:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks