Java Byte Array Dump dumpByteArray(byte[] b)

Here you can find the source of dumpByteArray(byte[] b)

Description

dump Byte Array

License

Open Source License

Return

length and data of a byte array, printed as decimal numbers

Declaration

public static String dumpByteArray(byte[] b) 

Method Source Code

//package com.java2s;
/*-//  w  ww .j  a  v  a  2 s.  c  o m
 *
 *  This file is part of Oracle Berkeley DB Java Edition
 *  Copyright (C) 2002, 2015 Oracle and/or its affiliates.  All rights reserved.
 *
 *  Oracle Berkeley DB Java Edition is free software: you can redistribute it
 *  and/or modify it under the terms of the GNU Affero General Public License
 *  as published by the Free Software Foundation, version 3.
 *
 *  Oracle Berkeley DB Java Edition 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 Affero
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License in
 *  the LICENSE file along with Oracle Berkeley DB Java Edition.  If not, see
 *  <http://www.gnu.org/licenses/>.
 *
 *  An active Oracle commercial licensing agreement for this product
 *  supercedes this license.
 *
 *  For more information please contact:
 *
 *  Vice President Legal, Development
 *  Oracle America, Inc.
 *  5OP-10
 *  500 Oracle Parkway
 *  Redwood Shores, CA 94065
 *
 *  or
 *
 *  berkeleydb-info_us@oracle.com
 *
 *  [This line intentionally left blank.]
 *  [This line intentionally left blank.]
 *  [This line intentionally left blank.]
 *  [This line intentionally left blank.]
 *  [This line intentionally left blank.]
 *  [This line intentionally left blank.]
 *  EOF
 *
 */

public class Main {
    /**
     * @return length and data of a byte array, printed as decimal numbers
     */
    public static String dumpByteArray(byte[] b) {

        StringBuilder sb = new StringBuilder();
        sb.append("<byteArray len = ");
        sb.append(b.length);
        sb.append(" data = \"");
        for (int i = 0; i < b.length; i++) {
            sb.append(b[i]).append(",");
        }
        sb.append("\"/>");
        return sb.toString();
    }
}

Related

  1. dump(byte[] str)
  2. dumpArray(byte b[])
  3. dumpArray(byte[] b)
  4. dumpArray(byte[] buffer, boolean breakLines)
  5. dumpByteArray(byte[] ab)
  6. dumpByteArray(byte[] buffer)
  7. dumpByteArray(byte[] bytes)
  8. dumpByteArrayAsInts(byte[] arr)
  9. dumpBytes(byte bb[])