I am facing some problems in a project regarding to byte fetching from a file and storing. Problem in java bytes is they are number, instead of char. In file i have seen a byte is like a char... Also how to make bytes unsigned , because signed bytes creates alot problem. Thanx in Advance.
Majestics
84
Posting Pro
Recommended Answers
Jump to PostA byte is 8 bits, nothing more. You may chose to interpret that as a number, or as a character, but that's up to you. The simple read() method for input streams places those 8 bits as the least significant 8 bits of an int variable, where you can use …
Jump to PostOK, I really can't bear the thought of you having to resort to C++
Here's a tiny runnable program that shows wrting all possible byte values to a file, then readingthem in and displaying them as signed values, unsigned values, and characters...import java.io.*; public class ByteIODemo …
All 5 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Majestics
84
Posting Pro
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Majestics
84
Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.