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 6031027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:07:25+00:00 2026-05-23T05:07:25+00:00

i am working on a project that gets the data from the file into

  • 0

i am working on a project that gets the data from the file into a byte array and adds “0” to that byte array until the length of the byte array is 224 bits. I was able to add zero’s but i am unable to confirm that how many zero’s are sufficient. So i want to print the file data in the byte array in binary format. Can anyone help me?

  • 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-05-23T05:07:26+00:00Added an answer on May 23, 2026 at 5:07 am

    For each byte:

    • cast to int (happens in the next step via automatic widening of byte to int)
    • bitwise-AND with mask 255 to zero all but the last 8 bits
    • bitwise-OR with 256 to set the 9th bit to one, making all values exactly 9 bits long
    • invoke Integer.toBinaryString() to produce a 9-bit String
    • invoke String#substring(1) to “delete” the leading “1”, leaving exactly 8 binary characters (with leading zeroes, if any, intact)

    Which as code is:

    byte[] bytes = "\377\0\317\tabc".getBytes();
    for (byte b : bytes) {
        System.out.println(Integer.toBinaryString(b & 255 | 256).substring(1));
    }
    

    Output of above code (always 8-bits wide):

    11111111
    00000000
    11001111
    00001001
    01100001
    01100010
    01100011
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m working on a project that basically will show some data collected from hardware
I am working on a project where the app parses data from an XML
I am currently working on a C# project that will export MySQL Data. The
I am working a project that does not have a trunk / branches /
I'm working on project that lets users choose some scientific authors and columnists and
Working on a project that parses a log of events, and then updates a
I am working on a project that requires the manipulation of enormous matrices, specifically
I'm working on a project that will be distributed with GNU autoconf/automake, and I
I'm working on a project that's been accepted as a proof of concept and
I am working on a project that has grown to a decent size, and

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.