Java Binary Encode toBinaryString(boolean[] array)

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

Description

to Binary String

License

Creative Commons License

Declaration

public static String toBinaryString(boolean[] array) 

Method Source Code

//package com.java2s;
/**//from w ww  .  j av  a  2 s.c om
 * A simple class comprised of various tools used in handling of boolean arrays and values.
 * 
 * @author Raymond Berg www.rwberg.org
 * 
 * Use is made available under the Creative Commons License. 
 * Feel free to use but leave attribution to original author throughout use.
 */

public class Main {
    public static String toBinaryString(boolean[] array) {
        char[] rawArr = new char[array.length];
        for (int i = 0; i < rawArr.length; i++) {
            rawArr[i] = toBinaryChar(array[i]);
        }
        return new String(rawArr);
    }

    public static char toBinaryChar(boolean bit) {
        return bit ? '1' : '0';
    }
}

Related

  1. toBinaryFromHex(byte ch)
  2. toBinaryID(final String id)
  3. toBinaryIeee754String(long decimal)
  4. toBinaryIntArray(byte[] bytes, int bitOffset, int bitCount)
  5. toBinaryName(String className)
  6. toBinaryString(byte b)
  7. toBinaryString(byte b)
  8. toBinaryString(byte... bytes)
  9. toBinaryString(byte[] array)