Java Bits Convert to bitsTo8Bytes(boolean[] bits)

Here you can find the source of bitsTo8Bytes(boolean[] bits)

Description

bits To Bytes

License

Open Source License

Declaration

public static byte[] bitsTo8Bytes(boolean[] bits) 

Method Source Code

//package com.java2s;
//    it under the terms of the GNU Lesser General Public License as published by

public class Main {
    public static byte[] bitsTo8Bytes(boolean[] bits) {
        byte[] b = new byte[8];
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                b[i] += (((bits[(8 * i) + j]) ? 1 : 0) << (7 - j));
            }/* ww w .  ja v a  2s.  c  o m*/
        }

        return b;
    }
}

Related

  1. BitsNeeded(int n)
  2. bitsRequired(double minValue, double maxValue)
  3. bitsRequired(int value)
  4. bitsRequiredForFraction(String floatnumber)
  5. bitsString2(byte b)
  6. bitsToBase64(byte data)
  7. bitsToDouble(String bits, double min, double max, int splits)
  8. bitsToFloats(boolean[] b)
  9. bitsToTransform(int src, int target)