Java Binary Encode toBinary(byte b)

Here you can find the source of toBinary(byte b)

Description

Just for debugging and testing purposes

License

Open Source License

Declaration

public static String toBinary(byte b) 

Method Source Code

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

public class Main {
    /** Most significant bits mask for binary operations */
    public static final int MOST_SIGNIFICANT_MASK = 0xFF;

    /** Just for debugging and testing purposes */
    public static String toBinary(byte b) {
        return String.format("%8s",
                Integer.toBinaryString(b & MOST_SIGNIFICANT_MASK)).replace(
                ' ', '0');
    }/*from   w w  w.  j a  v  a  2 s . c o  m*/
}

Related

  1. toBin(int size, String bitString)
  2. toBin(int x)
  3. toBin(long value, int width)
  4. toBinArray(String hexStr)
  5. toBinary(byte b)
  6. toBinary(byte b)
  7. toBinary(byte b)
  8. toBinary(byte[] bytes)
  9. toBinary(final byte[] array, final int offset, final int length)