Here you can find the source of bytesToBooleanArray(byte[] input)
public static boolean[] bytesToBooleanArray(byte[] input)
//package com.java2s; /**/*from ww w . j a v a 2 s.c o m*/ * <PRE> * Name : com.solidmatrix.regxmaker.util.shared.ArrayUtils * Project: RegXmaker Library * Version: 1.1 * Tier : N/A (Function Class) * Author : Gennadiy Shafranovich * Purpose: General utilities for array searching and matching * * Copyright (C) 2001, 2004 SolidMatrix Technologies, Inc. * This file is part of RegXmaker Library. * * RegXmaker Library is is free software; you can redistribute it and/or modify * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * RegXmaker library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Comments: Full, with javadoc. * * Modification History * * 02-19-2001 GS Created * * 02-19-2001 GS Ready for testing * * 02-23-2001 GS added byte to boolean convertion methods for patch library * * 06-18-2001 GS Fixed possible error in indexOf() methods. * * 06-21-2001 GS Fixed bug in indexOf() method. Values seemed to be * offset by one so -1 was inserted in many conditional * statements. * * 07-01-2001 GS Fixed bug in indexOf() method that cause an infinite * loop while searching. * * 07-05-2004 YS Added licensing information * </PRE> */ public class Main { /********************************************************** * Boolean-Byte section * * * * This section contains methods responsible for handling * * the convertion of flag arrays (boolean) into bytes * * that may be writen to outside files or other streams * * * **********************************************************/ public static final byte[] BIT_FLAGS = { (byte) 1, (byte) 2, (byte) 4, (byte) 8, (byte) 16, (byte) 32, (byte) 64, (byte) 128 }; /** * A method that performs the same function as the bytesToBooleanArray() * method but is not limited by input and output size. This method * can take an ultimited length byte array and will converted to a * boolean array equal in size to (8 * byte array size) */ public static boolean[] bytesToBooleanArray(byte[] input) { boolean[] out = new boolean[input.length * 8]; int pos = 0; for (int i = 0; i < input.length; i++) { for (int j = 0; j < 8; j++, pos++) { if ((input[i] & BIT_FLAGS[j]) == BIT_FLAGS[j]) out[pos] = true; else out[pos] = false; } //for } //for return out; } }