Here you can find the source of appendHexString(StringBuffer buffer, byte data)
public static void appendHexString(StringBuffer buffer, byte data)
//package com.java2s; /*************************************************************************** * Copyright (c) 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, Germany. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /*from w ww . j av a 2 s. c o m*/ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ public class Main { public static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', }; /** * Append hex string from byte to StringBuffer */ public static void appendHexString(StringBuffer buffer, byte data) { int positive = data < 0 ? ~data : data; buffer.append(HEX_DIGITS[positive >> 4]); buffer.append(HEX_DIGITS[positive & 0xf]); } }