Here you can find the source of bytesToBooleans(byte[] bytes)
Parameter | Description |
---|---|
bytes | a parameter |
protected static boolean[] bytesToBooleans(byte[] bytes)
//package com.java2s; /* $Revision: 159 $ $Date: 2009-08-17 12:52:56 +0000 (ma, 17 aug 2009) $ $Author: blohman $ * /*from w w w . j av a2 s . com*/ * Copyright (C) 2007-2009 National Library of the Netherlands, * Nationaal Archief of the Netherlands, * Planets * KEEP * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * For more information about this project, visit * http://dioscuri.sourceforge.net/ * or contact us via email: * jrvanderhoeven at users.sourceforge.net * blohman at users.sourceforge.net * bkiers at users.sourceforge.net * * Developed by: * Nationaal Archief <www.nationaalarchief.nl> * Koninklijke Bibliotheek <www.kb.nl> * Tessella Support Services plc <www.tessella.com> * Planets <www.planets-project.eu> * KEEP <www.keep-project.eu> * * Project Title: DIOSCURI */ public class Main { /** * Converts a byte[] into a boolean[] Each bit is converted into a boolean * value and placed in a boolean[]. * * @param bytes * @return boolean[] containing the converted bytes */ protected static boolean[] bytesToBooleans(byte[] bytes) { int tempValue = 0; boolean[] booleans = new boolean[bytes.length * 8]; // Build FLAGS register for (int b = bytes.length - 1; b >= 0; b--) { for (int j = 0; j < 8; j++) { // Convert flag into boolean tempValue = (bytes[b] >> j) & 0x01; if (tempValue == 1) { booleans[((bytes.length - 1 - b) * 8) + j] = true; } else { booleans[((bytes.length - 1 - b) * 8) + j] = false; } } } return booleans; } }