Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8242527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:11:53+00:00 2026-06-07T21:11:53+00:00

I am trying to figure out how to get to a specific byte in

  • 0

I am trying to figure out how to get to a specific byte in a binary file using java. I’ve done a ton of reading on byte level operations and have gotten myself thoroughly confused. Right now I can loop through a file, as in the code below, and tell it to stop at the byte I want. But I know that this is ham-fisted and there is a ‘right’ way to do this.

So for example if I have a file and I need to return the byte from off-set 000400 how can I a get this from a FileInputStream?

public ByteLab() throws FileNotFoundException, IOException {
        String s = "/Volumes/Staging/Imaging_Workflow/B.Needs_Metadata/M1126/M1126-0001.001";
        File file = new File(s);
        FileInputStream in = new FileInputStream(file);
        int read;
        int count = 0;
        while((read = in.read()) != -1){          
            System.out.println(Integer.toHexString(count) + ": " + Integer.toHexString(read) + "\t");
            count++;
        }
    }

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:11:54+00:00Added an answer on June 7, 2026 at 9:11 pm

    You need RandomAccessFile for the job. You can set the offset by the seek() method.

    RandomAccessFile raf = new RandomAccessFile(file, "r");
    raf.seek(400); // Goes to 400th byte.
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to structure a program using Java's generics, and
I am just trying to figure out if/how to get the Java Robot class
I'm trying to figure out to get rid of some spaces that Visual studio
I`m trying to figure out how to get serial and key attributes set for
I'm trying to figure out how to get the visible lines in a IWpfTextView
I'm trying to figure out how to get the index of the current rowspanned
I'm trying to figure out how to get the physical dimensions of a device's
I am trying to figure out how to get a json output in python
I'm trying to figure out how to get the users information after validating via
I'm trying to figure out how to get the distance of an li from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.