Results 1 to 6 of 6
  1. #1
    stegano is offline Member
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    0

    Default converting binary to string

    hi everyone,
    is there any method to convert binary to string?
    i know little about toString method but don't know how to use it..
    always give me error.. anyone?
    thanks in advance.

  2. #2
    stegano is offline Member
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    0

    Default

    fyi, i have declared an array as boolean..
    i have converted the text into binary and put it in the register,
    i want to do the reverse now
    so how i'm gonna deal with it?

  3. #3
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    Quote Originally Posted by stegano View Post
    fyi, i have declared an array as boolean..
    i have converted the text into binary and put it in the register,
    i want to do the reverse now
    so how i'm gonna deal with it?
    You should do SSCCE (Short, Self Contained, Correct Example) for this.

    Lets see what you have done so far

  4. #4
    stegano is offline Member
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    0

    Default

    XML Code:
    byte[] bytes = key.getBytes();
      		StringBuilder binary = new StringBuilder();
      		for (byte b : bytes) {
         			int val = b;
         			for (int i = 0; i < 8; i++) {
            			binary.append((val & 128) == 0 ? 0 : 1);
            			val <<= 1;
         			}
         			
      		}
    i have used this code above to convert text to binary
    can u tell me how to reverse it back?
    i have tried using toString() method but it only print 'true' or 'false'

    hmm... so how?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Double posted at
    conversion text-binary-text

    The discussion should continue here.

    db

  6. #6
    stegano is offline Member
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    0

Similar Threads

  1. Converting characters to decimal to binary
    By Majeh in forum New To Java
    Replies: 4
    Last Post: 02-04-2011, 11:06 PM
  2. Algorithm for converting binary/hex to decimal
    By addictz04 in forum New To Java
    Replies: 2
    Last Post: 11-29-2010, 06:49 PM
  3. converting to binary
    By telltera in forum New To Java
    Replies: 5
    Last Post: 09-02-2010, 02:35 PM
  4. Replies: 2
    Last Post: 07-09-2010, 12:37 PM
  5. Converting mp3 files to binary
    By kylefrank in forum Advanced Java
    Replies: 4
    Last Post: 06-09-2010, 08:25 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
  •