
Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
chuck <noemail@gmail.com> wrote, quoted or indirectly quoted someone who said :
>> I am having problems writing any value greater than 127 (out of ascii
>> range), i get random values.
> See http://mindprod.com/jgloss/unsigned.html
>
> bytes are -127..+127.
Also,
>> String encryptedString = padString(Long.toBinaryString(value[i]), -32, "0");
>> String bs0 = encryptedString.substring(0, 7+1);
>> int eByte0 = Integer.parseInt( bs0, 2);
Let's say value[i] is 33L. Long.toBinaryString() of that returns "100001".
You failed to show us padString(), but we'll assume that the result of that
operation is
"0000000000000000000000100001" (not long enough to represent a Long, BTW).
Now you parseInt() that String in base 2, which should yield the int value
corresponding to the binary string, which is the original value of 'value[i]'
if the latter is within the int range, an error if it's not.
Despite the name, eByte0 is an int.
So if value[i] is, say, 1023, then eByte0 when it's done will be 1023.
>> outfile.write( eByte0 );
will then write the string "1023" to the file.
You might as well have just said, "outfile.write( value[i] )". That at least
would handle the long values larger than Integer.MAX_VALUE.

Signature
Lew