Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Reading a file bit by bit

Posted on 2002-03-10
3
215 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet  URL Rewriting 1 42
couple of eclipse 5 45
Custom Java Application connects to database: Which one of the 20? 4 35
mysql jsp example issue 32 48
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

808 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