private static byte[] toByteArray(final CharSequence chars, final int length) {
		final byte[] array = Bits.newArray(length);
		for (int i = 0, j = length - 1; i < array.length; i++, j -= Byte.SIZE) {
			for (int bits = 0; bits < BITS.length && (j - bits) >= 0; ++bits) {
				if (get(chars, j - bits, length) == '1') {
					array[i] |= (byte)BITS[bits];
				}
			}
		}
		return array;
	}
Creates a new bit-array from the given string {@code value}. The given
{@code length} might be bigger and smaller than the length of the given
{@code value} string. The higher order bits of the created bit-array are
trimmed or filled with zero if the {@code length} is smaller or bigger
than the given string.

@see #of(CharSequence)
@see #toString()

@param value the given input string, consisting only of '0's and '1's
@param length the length of the created bit-array
@return a new bit-array from the given input {@code value}
@throws IllegalArgumentException if the given input {@code value} is
        empty
jenetics/src/main/java/io/jenetics/internal/collection/BitArray.java