Results 1 to 2 of 2
  1. #1
    akeni is offline Member
    Join Date
    Oct 2011
    Posts
    31
    Rep Power
    0

    Default Converting Chars to 8 -bit binary.

    Some few quick questions:

    1. what class do i need to use other than java.lang?
    2. Should i convert char to strings first or should i change it into ASCII decimal format and then to binary?

    Thanks in advance ;).

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: Converting Chars to 8 -bit binary.

    See Integer and its "bitstring" methods (you need to left pad the resulting strings, however). Also, don't forget, that java chars are 2 byte chars, so what are you to do with the characters? Split every one into two bytes? Only use one byte for those characters that will fit into one byte? Always only use the second byte? Restrict allowable character encodings of the input to a single byte encoding and use only the second byte? etc, etc, etc.

Similar Threads

  1. converting binary to string
    By stegano in forum New To Java
    Replies: 5
    Last Post: 03-27-2011, 08:20 PM
  2. converting to binary
    By telltera in forum New To Java
    Replies: 5
    Last Post: 09-02-2010, 03:35 PM
  3. Replies: 2
    Last Post: 07-09-2010, 01:37 PM
  4. Converting mp3 files to binary
    By kylefrank in forum Advanced Java
    Replies: 4
    Last Post: 06-09-2010, 09:25 PM
  5. Converting a text file int binary
    By sruthi_2009 in forum New To Java
    Replies: 0
    Last Post: 03-23-2009, 04:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •