Here you can find the source of booleanArrayToBitString(final boolean[] booleanArray)
Parameter | Description |
---|---|
booleanArray | the given boolean array |
public static String booleanArrayToBitString(final boolean[] booleanArray)
//package com.java2s; /*//from w w w .ja v a2 s. c o m * StringUtils.java * * Created on October 4, 2006, 2:36 PM * * Description: * * Copyright (C) 2006 Stephen L. Reed. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ public class Main { /** Returns a bit-string representation of the given boolean array. * * @param booleanArray the given boolean array * @return a bit-string representation of the given boolean array */ public static String booleanArrayToBitString(final boolean[] booleanArray) { final StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < booleanArray.length; i++) { if (booleanArray[i]) { stringBuilder.append('1'); } else { stringBuilder.append('0'); } } return stringBuilder.toString(); } }