Java tutorial
//package com.java2s; /** * Copyright (c) 2013 Cisco Systems, Inc. and others. 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 */ import com.google.common.primitives.UnsignedBytes; public class Main { private static final char[] HEX = "0123456789ABCDEF".toCharArray(); private static final void appendByte(final StringBuilder sb, final byte b) { int v = UnsignedBytes.toInt(b); sb.append(HEX[v >>> 4]); sb.append(HEX[v & 15]); } }