Roderik said:
I tried:
System.out.println(Integer.toString(dis.readByte(), 16).toUpperCase());
which results in:
-1
12
-1
34
-1
56
-1
-56
-1
-44
3B
3
-1 should be FF. The only right output values are the last two bytes.
Why should negative one be two hundred fifty-five?
And why do you think a `byte' should be able to hold so
large a value, since its range goes from -128 through +127?
If you ponder this for a minute or two, I think you'll
solve at least part of your problem.
You've provided no means to study your claim that only
the final two values are "right," since you haven't shown a
sample of the input stream's data. Nor have you explained
what "rightness" is; from your -1 vs. FF confusion I'd have
guessed that the second, fourth, and sixth lines would also
be considered "right," but apparently you have some other
criterion in mind.
Any idea how I can output the bytes to the console the way a hex editor
would do.
I *had* an idea, but it wouldn't change the second, fourth,
or sixth lines -- and since these are "wrong," my idea probably
isn't what you're after. Sorry.