how to convert binary to string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manodrekha
    New Member
    • Mar 2015
    • 1

    how to convert binary to string

    Code:
    byte[] bytes = s.getBytes();
      StringBuilder binary = new StringBuilder();
      for (byte b : bytes)
      {
         int val = b;
         for (int j = 0; j < 8; j++)
         {
            binary.append((val & 128) == 0 ? 0 : 1);
            val <<= 1;
         }
         binary.append(' ');
      }
    in this pgm I have converted string to binary....from this pgm how can I convert it to back
    Last edited by Rabbit; Mar 30 '15, 04:06 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...