Solved

Reading a file bit by bit

Posted on 2002-03-10
3
201 Views
Last Modified: 2010-03-31
I may be a bit ignorant but I'm assuming I could read and write any file bit by bit (ie. 1's and 0's).

Just to satisfy my own curiosity I would like to write a simple class that would take a filename, read it in and write 1's and 0's out to the screen and at the same time write this data to another file, essentially copying the file but also displaying it bit by bit.

I have done some reasearch into datainputstream which can return bytes but I would like to be able to see the bits?

Is this possible and is there a class that would do this for me?
0
Comment
Question by:unhappygilmore
3 Comments
 
LVL 4

Accepted Solution

by:
m_onkey_boy earned 75 total points
ID: 6855134
The byte is the smallest unit you can manipulate directly.  If you want to display the ones and zeros, you can read each byte and then use Integer.toBinaryString to get the binary representation of the bytes in String form.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7902056
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: m_onkey_boy
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7962650
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now