Here you can find the source of toHexStream(ByteBuffer data)
Parameter | Description |
---|---|
data | a parameter |
public static String toHexStream(ByteBuffer data)
//package com.java2s; /**/*from w w w. j a v a 2 s .c o m*/ * This file is part of Aion-Lightning <aion-lightning.org>. * * Aion-Lightning 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. * * Aion-Lightning 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 Aion-Lightning. * If not, see <http://www.gnu.org/licenses/>. */ import java.nio.ByteBuffer; public class Main { /** * Convert data from given ByteBuffer to hex * * @param data * @return hex */ public static String toHexStream(ByteBuffer data) { StringBuilder result = new StringBuilder(); int counter = 0; int b; while (data.hasRemaining()) { b = data.get() & 0xff; result.append(String.format("%02X ", b)); counter++; if (counter % 16 == 0) { result.append("\n"); } } return result.toString(); } }