Here you can find the source of dumpBytes(ByteBuffer byteBuffer)
Parameter | Description |
---|---|
byteBuffer | the byteBuffer to be dumped |
public static String dumpBytes(ByteBuffer byteBuffer)
//package com.java2s; /*/*from w w w .j a va2 s. c o m*/ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * * 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; version 2 of the License. * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ import java.nio.ByteBuffer; public class Main { /** Convert the byte[] into a String to be used for logging and debugging. * * @param bytes the byte[] to be dumped * @return the String representation */ public static String dumpBytes(byte[] bytes) { StringBuffer buffer = new StringBuffer("byte["); buffer.append(bytes.length); buffer.append("]: ["); for (int i = 0; i < bytes.length; ++i) { buffer.append((int) bytes[i]); buffer.append(" "); } buffer.append("]"); return buffer.toString(); } /** Convert the byteBuffer into a String to be used for logging and debugging. * * @param byteBuffer the byteBuffer to be dumped * @return the String representation */ public static String dumpBytes(ByteBuffer byteBuffer) { byteBuffer.mark(); int length = byteBuffer.limit() - byteBuffer.position(); byte[] dst = new byte[length]; byteBuffer.get(dst); byteBuffer.reset(); return dumpBytes(dst); } }