File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How do I get the delete flag to display in the right format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How do I get the delete flag to display in the right format" Watch "How do I get the delete flag to display in the right format" New topic
Author

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

Alex Hartman
Greenhorn

Joined: Oct 11, 2009
Posts: 7
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
Bartender

Joined: Jul 19, 2004
Posts: 5534
    
  13

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


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Alex Hartman
Greenhorn

Joined: Oct 11, 2009
Posts: 7
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
Bartender

Joined: Jul 19, 2004
Posts: 5534
    
  13

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

Joined: Dec 28, 2007
Posts: 2267
    
    3

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?


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do I get the delete flag to display in the right format