• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading 6 bytes?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic