Java Utililty Methods Bit String From

List of utility methods to do Bit String From

Description

The list of methods to do Bit String From are organized into topic(s).

Method

StringtoBitString(byte[] bytes)
to Bit String
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
    if (i != 0) {
        sb.append(" ");
    sb.append(toString(bytes[i]));
return sb.toString();
...
StringtoBitString(byte[] bytes, final int digitsPerGroup, final String groupSeparator)
to Bit String
if (digitsPerGroup <= 0 || (digitsPerGroup & 7) != 0) {
    throw new IllegalArgumentException(
            "digitsPerGroup <= 0 || (digitsPerGroup & 1) != 0, digitsPerGroup=" + digitsPerGroup);
final StringBuilder b = new StringBuilder();
int r = 0;
for (int i = bytes.length - 1; i >= 0; i--) {
    b.append(BIT_STRINGS[bytes[i] >>> 4]).append(BIT_STRINGS[bytes[i] & 0xF]);
...
StringtoBitString(byte[] data)
to Bit String
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.length * 8; i++) {
    sb.append(getBit(data, i));
return sb.toString();
StringtoBitString(final byte n)
Returns a String representation of the bits in a byte.
final int tmp = n;
final StringBuffer sb = new StringBuffer(8);
for (int i = 7; i >= 0; i--) {
    if ((tmp & (1 << i)) >> i == 1) {
        sb.append('1');
    } else {
        sb.append('0');
return sb.toString();
StringtoBitString(final byte[] b)
Return the binary representation of the unsigned byte[].
if (b == null)
    throw new IllegalArgumentException();
final char[] chars = new char[b.length << 3]; 
int bitIndex = 0; 
for (int i = 0; i < b.length; i++) {
    final byte x = b[i]; 
    for (int withinByteIndex = 7; withinByteIndex >= 0; withinByteIndex--) {
        final int mask = 1 << withinByteIndex;
...
StringtoBitString(final byte[] b)
to Bit String
final char[] bits = new char[8 * b.length];
for (int i = 0; i < b.length; i++) {
    final byte byteval = b[i];
    int bytei = i << 3;
    int mask = 0x1;
    for (int j = 7; j >= 0; j--) {
        final int bitval = byteval & mask;
        if (bitval == 0) {
...
StringtoBitString(final double d)
to Bit String
final char[] bit = new char[64];
final long dd = Double.doubleToLongBits(d);
long mask = 1L;
for (int i = 0; i < 64; i++) {
    final long bitval = dd & mask;
    if (bitval == 0) {
        bit[63 - i] = '0';
    } else {
...
voidtoBitString(final StringBuilder sb, final byte value, final int count2)
to Bit String
int count = count2;
if (count > 8) {
    count = 8;
char[] data = new char[count];
for (int pos = 0; pos != count; ++pos) {
    if ((value & (1 << pos)) != 0) {
        data[count - pos - 1] = '1';
...
StringtoBitString(int i)
to Bit String
StringBuilder bitString = new StringBuilder();
do {
    bitString.append(String.valueOf(i % 2));
} while ((i /= 2) > 0);
return bitString.reverse().toString();
StringtoBitString(int meta)
to Bit String
StringBuilder sb = new StringBuilder();
for (int k = 0; k < 4; k++) {
    if (((meta >> k) & 1) == 1) {
        sb.append(1);
    } else {
        sb.append(0);
return sb.toString();