Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reading a file bit by bit

Posted on 2002-03-10
3
Medium Priority
?
241 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

916 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