File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading 6 bytes?

 
Howard lyee
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my database Scheme(Bodgitt and Scarper) the size fields is worth 6 bytes. What method do I use to read it in the randomAccess File Class. Thanks.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Howard,

Welcome to JavaRanch and this forum.

Just above the "Database schema" section there is usually a sentence such as "All text values, and all fields (which are text only), contain only 8 bit characters..." - do you have this sentence?

If you do have this sentence, then it means that the size field is stored as the text representation of the number. So you can use the methods you are using to read all the other text fields.

Regards, Andrew
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That been said, you can read 6 bytes using the read(byte[]) or read(byte[], int off, int len) method signatures.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it would be worthwhile to study the difference between the read(byte[]) and readFully(byte[]) methods. For an array as small as 6 bytes it's fairly unlikely that the difference will be noticed, most of the time. However this is the sort of little detail that can lead to rare unexplained errors, so it's good to avoid this problem in the first place if possible.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic