Here you can find the source of toBinaryString(byte... bytes)
public static String toBinaryString(byte... bytes)
//package com.java2s; /******************************************************************************* * Copyright (c) 2018 Arrow Electronics, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License 2.0 * which accompanies this distribution, and is available at * http://apache.org/licenses/LICENSE-2.0 * * Contributors:/*from w ww.ja v a2 s .com*/ * Arrow Electronics, Inc. *******************************************************************************/ public class Main { public static String toBinaryString(byte... bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { if (sb.length() > 0) { sb.append(' '); } sb.append(Integer.toBinaryString(256 + b)); } return sb.toString(); } }