NullPointerException: null (in sun.misc.Floating Decimal) Error?

Thread Solved

Join Date: Apr 2009
Posts: 12
Reputation: Atomika3000 is an unknown quantity at this point 
Solved Threads: 0
Atomika3000's Avatar
Atomika3000 Atomika3000 is offline Offline
Newbie Poster

NullPointerException: null (in sun.misc.Floating Decimal) Error?

 
0
  #1
Apr 26th, 2009
I am getting further with my Property to let program, but i need help working out the above error, it happens when the user selects the option to delete a property from the text file.

The user is supposed to be able to enter in a number and that deletes the line that that number corresponds to.

  1. if(i == 2)
  2. {
  3. try
  4.  
  5. {
  6. BufferedReader br=new BufferedReader(new FileReader("properties.txt"));
  7. String line=null;
  8. while ((line=br.readLine()) != null)
  9. {
  10. String[] addy=line.split(",");
  11. PropertyToLet ptl=new PropertyToLet(addy[0],addy[1],addy[2]);
  12. v.addElement(ptl);
  13. }
  14. System.out.println("\nEnter the line number of the property you wish to remove");
  15. //its at this line the errors occurs
  16. ln = Double.valueOf(br.readLine()).intValue();
  17. v.removeElementAt(ln);
  18. PrintWriter outFile = new PrintWriter(new FileWriter("properties.txt"));
  19. for (int i=0; i<v.size(); i++)
  20. {
  21. PropertyToLet obj = (PropertyToLet) (v.lastElement());
  22. outFile.println(obj.getpc() + "," + obj.gethn() + "," + obj.getmr());
  23. }
  24. outFile.close();
  25. }
  26. catch(ArrayIndexOutOfBoundsException aioobe)
  27. {
  28. System.out.println("An Error Has occurred");
  29. }
  30. catch(IOException ex)
  31. {
  32. ex.printStackTrace();
  33. }
  34.  
  35. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 12
Reputation: Atomika3000 is an unknown quantity at this point 
Solved Threads: 0
Atomika3000's Avatar
Atomika3000 Atomika3000 is offline Offline
Newbie Poster

Re: NullPointerException: null (in sun.misc.Floating Decimal) Error?

 
0
  #2
Apr 26th, 2009
The delete section works when i replace the line

  1. ln = Double.valueOf(br.readLine()).intValue();

with

  1. ln=2

i would use this if i could but the user needs to be able to select the line...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC