| Author |
string to byte array problem
|
Ravindra Harige
Ranch Hand
Joined: Jun 10, 2005
Posts: 33
|
|
hello, I've long sequence of 0 and 1's in a string and i want this string to be stored in a byte array,but the size of byte array should be ( [number of 0's and 1's in string]/8 ) for example,if i've 80 consecutive 0's and 1's in a string then i want a byte array of size 10 consisting of the exact sequence of 0's and 1's as in string. please help me on how to go about this.. regards
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
First of all you must decide what to do if the length is not a multiple of 8. Do you add zeros at the start? At the end? Something else? But lets suppose you've solved that, and the string is now in the right format. You can use something similar to this: [ March 24, 2008: Message edited by: Rob Prime ]
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: string to byte array problem
|
|
|