Here you can find the source of toBinString(byte value)
public static String toBinString(byte value)
//package com.java2s; /**/*w w w . j ava2s. co m*/ * EKO : A Peer To Peer Application * Copyright (c) J?r?me Bonnet 2008-2009 * All Rights Reserved * * Unless you own a different specific license for this program, * 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 3 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, see <http://www.gnu.org/licenses/>. * * * A moins que vous ne disposer d'une licence diff?rente pour ce programme, Ce programme est libre, vous pouvez le redistribuer et/ou le modifier selon les termes de * la Licence Publique G?n?rale GNU publi?e par la Free Software Foundation (version 3). * * Ce programme est distribu? car potentiellement utile, mais SANS AUCUNE GARANTIE, ni explicite ni implicite, y compris les garanties de commercialisation ou d'adaptation * dans un but sp?cifique. Reportez-vous ? la Licence Publique G?n?rale GNU pour plus de d?tails. * * Vous devez avoir re?u une copie de la Licence Publique G?n?rale GNU en m?me temps que ce programme ; si ce n'est pas le cas, ?crivez ? la Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, ?tats-Unis. */ public class Main { public static String toBinString(byte value) { StringBuilder sb = new StringBuilder(Integer.toBinaryString(Integer.valueOf(value & 0xff))); while (sb.length() < 8) sb.insert(0, '0'); return sb.toString(); } }