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

  • SEARCH
  • Home
  • 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 340037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:34:44+00:00 2026-05-12T10:34:44+00:00

I have a custom image file where the first block of data is ASCII

  • 0

I have a custom image file where the first block of data is ASCII meta data. I need to be able to read this ASCII meta-data part of the file with Java and know when it ends, and when the ‘raw image data’ in another encoding starts.

I was thinking of reading all of the file into a byte[], and then somehow either start reading bytes out of this and convert them to ASCII until I hit the end of the ascii meta-data section, at which point I would store this data. Then I could just rearrange the raw binary data in a different order as-is (no reading necessary). However, the only way I could think about doing this would be to read the ascii stuff byte-by-byte and look for new lines, and concat everything prior to a new line and see if that is the tag which signifies the beginning of the raw image data. However, there must be a better way of reading the ascii part of the file with readLine() and then be able to immediately start with the raw image binary without needed to reopen the file in a new reader and go to the line where in the other reader I found the ‘begin image’ tag.

Any ideas?

  • 1 1 Answer
  • 1 View
  • 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-05-12T10:34:44+00:00Added an answer on May 12, 2026 at 10:34 am
    • Open the file as FileInputStream (wrapped in a BufferedInputStream)
    • Create a ByteArrayOutputStream
    • Read the input stream byte by byte, looking for your “begin image” tag using a string searching algorithm. Cast individual bytes to char (that’s using ASCII implicitly)
    • At the same time, write each byte you’ve looked at into the ByteArrayOutputStream
    • Once you’ve found the tag, you can start reading the image data from the input stream
    • Get the byte array from the ByteArrayOutputStream and convert it to a String using new String(array, "US-ASCII");

    It might be possible to do the string searching easily by using a Scanner on the input stream, but you have to be careful which pattern you use to make sure it will find the tag without starting to read the image data (since you want to read that yourself from the underlying input stream you’re keeping a separate reference to).

    Edit: Unfortunately, it looks like Scanner implicitly uses a buffer as well, so the only option left is to implement the string search “manually”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom map image with specific height and width. i need to map
I have transformed a custom image header into an image rotator by using this
I have a custom background image on one of my Wordpress login pages. After
I have an image editing application, and I have custom adorners which get added
I have a custom UITableViewCell which has an image & and some text. When
I have created custom cell in which there are n number of image views.
I have a custom list, and I've added a 'Page Image' field by clicking
I have a listview with custom row having a textview and a clickable image
I have a custom asp.net server control to display images.What I need now is
I have a custom feature which is an Edit Control Block (ECB) action in

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.