Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I get the delete flag to display in the right format

 
Alex Hartman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have been reading this forum for a while now and have gotten a lot of my questions in regards to the SCJD cert answered by browsing through the different posts.
I am currently working on the DB Access part of the cert. Actually, it's going pretty good, but there is one little thing I cannot figure out.
Before reading a record into a byte array and making a String out of it, I use the readByte() method to read in the status/delete flag for every record. I then convert the byte to an int and save it into an ArrayList. For some reason, when printing my status flag/delete flag variable it displays as "32" and not "0." I would really like to figure out how to get it into the right format and have it display as 0. Anyways, any advice is appreciated.

Thanks in advance,

Al
 
Roel De Nijs
Sheriff
Posts: 9933
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,

Welcome to the JavaRanch and good luck with your assignment.

Did you already tried this excellent tool for reading your database file?

Kind regards,
Roel
 
Alex Hartman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Roel,

Thank you for the welcome, and, yes, I did utilize the tool and it worked great . However, when replacing the inputstream by a RandomAccessFile, the status flag/delete flag value does not display as 0 anymore, but as 32. As I said in my initial post, I maneuver directly to the status flag location e.g.,

I tried this in multiple ways, with the same end result: The value stored ends up being 32. Maybe I am getting worked up over nothing here but I would really like to know why the read-in value does not display correctly when using a RAF .
 
Roel De Nijs
Sheriff
Posts: 9933
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,

I used this small (self-written) program to read my database file. Maybe you can give it a try (maybe make some small changes):


And the output of this program is (small snippet):

So the delete-flag is displayed as expected.

Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Alex!

Champion, you really shouldn't be having problems to read your file with the DBFileReader tool, no matter if you are using FileInputStream or RandomAccessFile. Do you get any IOException or the status flag is just displayed wrongly?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic