Here you can find the source of byteToBooleanArray(byte input)
Parameter | Description |
---|---|
input | a single byte to be converted |
public static boolean[] byteToBooleanArray(byte input)
//package com.java2s; /**/*from w ww. j a va 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 }; /** * This method can be used to convert a byte into an array of * boolean values. The resulting boolean array will be of size 8. * For converting byte arrays into boolean arrays it is recommended * to use the bytesToBooleanArray() method. The values will be * converted in left to right order. The first value in the output * array will be the least significant bit of the input byte. * * @param input a single byte to be converted * @return array of booleans of size 8 */ public static boolean[] byteToBooleanArray(byte input) { boolean[] out = new boolean[8]; for (int i = 0; i < 8; i++) { if ((input & BIT_FLAGS[i]) == BIT_FLAGS[i]) out[i] = true; else out[i] = false; } //for return out; } }