Java Boolean Convert to booleanArrayToBitString(final boolean[] booleanArray)

Here you can find the source of booleanArrayToBitString(final boolean[] booleanArray)

Description

Returns a bit-string representation of the given boolean array.

License

Open Source License

Parameter

Parameter Description
booleanArray the given boolean array

Return

a bit-string representation of the given boolean array

Declaration

public static String booleanArrayToBitString(final boolean[] booleanArray) 

Method Source Code

//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();
    }
}

Related

  1. boolean2array(int sz, boolean seed)
  2. boolean2bin(boolean b)
  3. boolean2byte(boolean b)
  4. boolean2double(boolean b)
  5. boolean2long(boolean b)
  6. booleanArrayToBytes(boolean[] input)
  7. booleanArrayToInt(boolean[] in)
  8. booleanArrayToIntIndexes(boolean[] arrb)
  9. booleanArrayToString(boolean[] array)