Java Binary Encode toBinaryString(byte[] array)

Here you can find the source of toBinaryString(byte[] array)

Description

to Binary String

License

Open Source License

Declaration

public static String toBinaryString(byte[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toBinaryString(byte b) {
        return String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0');
    }/*from   ww  w .  j a  va2s  . c  o  m*/

    public static String toBinaryString(byte[] array) {
        StringBuffer sb = new StringBuffer();
        for (byte b : array) {
            sb.append(toBinaryString(b));
            sb.append(" ");
        }

        return sb.toString();
    }
}

Related

  1. toBinaryName(String className)
  2. toBinaryString(boolean[] array)
  3. toBinaryString(byte b)
  4. toBinaryString(byte b)
  5. toBinaryString(byte... bytes)
  6. toBinaryString(byte[] bytes)
  7. toBinaryString(byte[] bytes)
  8. toBinaryString(byte[] bytes, int bitSize)
  9. toBinaryString(byte[] data, boolean format)