Results 1 to 2 of 2
  1. #1
    vinayak.top is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default Convert String to Binary equivalent

    Hi I need to convert a String to its equivalent binary representation.
    for example "hello" must be converted to a binary equivalent of length 40 bits.
    i.e each character in a string must generate a binary value of 8 digits.

    Please help me

    it is very urgent...

    Thank you in advance...

  2. #2
    hadi is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default

    You could use getBytes method from String class . for example :
    String s = "hello" ;
    byte[] b = s.getBytes();
    and then convert bytes to binary representation with Integer.toBinaryString(b[0]);

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2010, 12:40 PM
  2. Convert String to Binary
    By erakhman in forum New To Java
    Replies: 1
    Last Post: 09-01-2010, 08:25 AM
  3. Replies: 4
    Last Post: 10-26-2009, 10:17 PM
  4. convert binary to images
    By fiqueudrue in forum New To Java
    Replies: 3
    Last Post: 02-12-2009, 09:16 AM
  5. Use recursion to convert binary to...
    By coco in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 07:46 AM

Posting Permissions

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