• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

string to byte array problem

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic