Here you can find the source of appendHex(StringBuilder sb, ByteBuffer bb)
public static StringBuilder appendHex(StringBuilder sb, ByteBuffer bb)
//package com.java2s; /*/* w ww . jav a 2 s . c om*/ * ***** BEGIN LICENSE BLOCK ***** * Zimbra Collaboration Suite Server * Copyright (C) 2007, 2009, 2010, 2011, 2013, 2014, 2016 Synacor, Inc. * * 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, see <https://www.gnu.org/licenses/>. * ***** END LICENSE BLOCK ***** */ import java.nio.ByteBuffer; public class Main { public static StringBuilder appendHex(StringBuilder sb, ByteBuffer bb) { int limit = bb.limit(); for (int i = bb.position(); i < limit; i++) { int c = bb.get(i) & 0xff; sb.append(Character.forDigit(c >> 4, 16)); sb.append(Character.forDigit(c & 0xf, 16)); if (i < limit - 1) sb.append(' '); } return sb; } }