Results 1 to 3 of 3
  1. #1
    jkurth is offline Member
    Join Date
    Nov 2007
    Posts
    3
    Rep Power
    0

    Default reading a binary file with a RAF

    I am working on a program where I am to access a binary file and read information from it, and use the info to perform different tasks. I know the file first has an index number of type long, and was told I must read the first 9 bits to see this. When I read in these bits and print them, it displays 000000050, which is what I want, the 50 part, but how do I actually make use of what I read in? Is there a good way to add each byte to a list and convert to an int?

    Some of the data is not known as to how long the length or number of characters are in a string. The length is of type short. Is there a way to determine what the number bytes to read is?

  2. #2
    jkurth is offline Member
    Join Date
    Nov 2007
    Posts
    3
    Rep Power
    0

    Default

    I am able to read the file for the sets of data in which i know how far I need to go, where the index of 50 is a set long, so the readLong() method works fine, and the next 9 chars can be read with the readChar() method for the reference number of the actual data. The part I don't understand how to do is figure out how far to read for the next set of data which is the name of the data. The amount of characters to read is of type short, which is all I know. I heard of some method where java can determine the amount of characters to read, because it is in a block, however, I am unsure of this. hope this clears up what it is I am asking to do.

  3. #3
    Join Date
    Dec 2007
    Posts
    6
    Rep Power
    0

    Default

    hi jkurth,

    I am also working on similar kind of requirement. Can u pls post the code which u hav written.

Similar Threads

  1. Reading a Field in a Binary File
    By janakiram.attuluri in forum Advanced Java
    Replies: 2
    Last Post: 01-09-2008, 11:47 AM
  2. Reading a file
    By mew in forum New To Java
    Replies: 2
    Last Post: 12-30-2007, 01:23 PM
  3. Reading Binary File and Changing data
    By janakiram.attuluri in forum Advanced Java
    Replies: 1
    Last Post: 12-21-2007, 11:10 AM
  4. How to load binary content of a .class file
    By boy22 in forum Advanced Java
    Replies: 1
    Last Post: 08-03-2007, 07:21 PM
  5. Reading from a file
    By leebee in forum New To Java
    Replies: 1
    Last Post: 07-23-2007, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •