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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:27:43+00:00 2026-05-24T20:27:43+00:00

How can i convert File to Binary? I just need it for my project.

  • 0

How can i convert File to Binary? I just need it for my project. I need to encrypt a file by its binaries.

  • 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-24T20:27:46+00:00Added an answer on May 24, 2026 at 8:27 pm

    If you’re referring to accessing the ACTUAL BINARY form then read in the file and convert every byte to a binary representation…

    EDIT:

    Here’s some code to convert a byte into a string with the bits:

    String getBits(byte b)
    {
        String result = "";
        for(int i = 0; i < 8; i++)
            result += (b & (1 << i)) == 0 ? "0" : "1";
        return result;
    }
    

    If you’re referring to accessing the bytes in the file then simply use the following code (you can use this for the first case as well):

    File file = new File("filename.bin");
    byte[] fileData = new byte[file.length()];
    FileInputStream in = new FileInputStream(file);
    in.read(fileData):
    in.close();
    // now fileData contains the bytes of the file
    

    To use these two pieces of code you can now loop over every byte and create a String object (8X larger than the original file size!!) with the bits:

    String content = "";
    for(byte b : fileData)
        content += getBits(b);
    // content now contains your bits.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert image sequences(ie,png) to video file in iPhone. How i can
I receive a binary pdf file, which is base64Binary encoded. How can I convert
How can I convert Visio binary file (.vsd extension) to Visio xml file(.vdx extension)
There's this program, pdftotext, that can convert a pdf file to a text file.
How can we convert data displayed in a reportviewer to an xml file?
Possible Duplicate: How can I convert my java program to an .exe file ?
How can I export the private key embedded in an .cer file and convert
i want to convert my webpage(displayed in UIWebView) contents in pdf file. which can
I have a binary file of doubles that I need to load using C++.
I have a file with binary data and I need to replace a few

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.