Java Binary Encode toBinary(byte[] bytes)

Here you can find the source of toBinary(byte[] bytes)

Description

to Binary

License

Open Source License

Declaration

public static String toBinary(byte[] bytes) 

Method Source Code

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

public class Main {
    public static String toBinary(byte[] bytes) {
        StringBuilder sb = new StringBuilder(bytes.length * Byte.SIZE);
        for (int i = 0; i < Byte.SIZE * bytes.length; i++) {
            sb.append((bytes[i / Byte.SIZE] << i % Byte.SIZE & 0x80) == 0 ? '0'
                    : '1');
        }/*  ww  w .  j a  va  2s  .c  om*/
        return sb.toString();
    }
}

Related

  1. toBinArray(String hexStr)
  2. toBinary(byte b)
  3. toBinary(byte b)
  4. toBinary(byte b)
  5. toBinary(byte b)
  6. toBinary(final byte[] array, final int offset, final int length)
  7. toBinary(final byte[] bytes)
  8. toBinary(final double d)
  9. toBinary(final double d)