Here you can find the source of appendHexByte(byte b, StringBuffer buf)
Parameter | Description |
---|---|
b | the byte to write. |
out | the string buffer to write to. |
public static void appendHexByte(byte b, StringBuffer buf)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww .j a v a 2 s. c om*/ * Append a byte in hexadecimal form, as two ASCII bytes, e.g. "5F" for 0x5F, to a StringBuffer. * * @param b the byte to write. * @param out the string buffer to write to. */ public static void appendHexByte(byte b, StringBuffer buf) { // Write first char char c = (char) ((b >> 4) & 0xF); if (c > 9) c = (char) ((c - 10) + 'A'); else c = (char) (c + '0'); buf.append(c); // Write second char c = (char) (b & 0xF); if (c > 9) c = (char) ((c - 10) + 'A'); else c = (char) (c + '0'); buf.append(c); } }