Java Byte Array Print printBytes(byte[] bytes)

Here you can find the source of printBytes(byte[] bytes)

Description

print Bytes

License

Open Source License

Declaration

public static void printBytes(byte[] bytes) 

Method Source Code

//package com.java2s;
/*//from w  w w.  j  av a2 s  . c  om
 * Copyright 2012-15 Fraunhofer ISE
 *
 * This file is part of jDLMS.
 * For more information visit http://www.openmuc.org
 *
 * jDLMS 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.
 *
 * jDLMS 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 jDLMS.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

public class Main {
    public static void printBytes(byte[] bytes) {
        StringBuilder sb = new StringBuilder();

        for (byte b : bytes) {
            String byteString = Integer.toHexString(b & 0x000000FF);
            byteString = byteString.length() == 1 ? "0" + byteString : byteString;
            sb.append(byteString);
        }

        System.out.println(sb.toString());
    }
}

Related

  1. printByteArrayToHex(byte[] byteArray, int length)
  2. printByteHexEncoded(byte b)
  3. printBytes(byte[] ba)
  4. printBytes(byte[] buffer, int start, int length)
  5. printBytes(byte[] bytes)
  6. printBytes(byte[] bytes)
  7. printBytes(byte[] bytes)
  8. printBytes(byte[] bytes, int offset)
  9. printBytes(byte[] data)