Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Andrew's Read DB Method

 
Shan Jun Hao
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to do what Andrew has demostrated in his book.



I keep on getting errors with the short value - java.lang.NumberFormatException: For input string: "". Can anyone tell me how to convert the String to a short value?
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You read two bytes, that I believe creates String with characters below ' ' (0x32). So it is trimmed to "" (as described in api for trim).
 
Daniel Bryant
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shan,

I personally read the two bytes indicating a deleted flag before reading the rest of the record from the file - that way you can read the two bytes directly into a byte array (bypassing the need for conversion) and check if the record is deleted or not.

The added bonus of this approach is that if you determine a record is deleted you do not need to read the rest of the record, and accordingly save valuable time synchronizing and reading the DB file.

Best wishes,

Daniel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic