Java Hex String Create appendHexByte(final StringBuilder sb, final byte b)

Here you can find the source of appendHexByte(final StringBuilder sb, final byte b)

Description

append Hex Byte

License

Open Source License

Declaration

private static final void appendHexByte(final StringBuilder sb,
            final byte b) 

Method Source Code

//package com.java2s;
/*//from   w w  w.  j av a  2 s  .  c o  m
 * Copyright (c) 2016 Pantheon Technologies s.r.o. 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
 */

public class Main {
    private static final char[] HEX_CHARS = "0123456789abcdef"
            .toCharArray();

    private static final void appendHexByte(final StringBuilder sb,
            final byte b) {
        final int v = Byte.toUnsignedInt(b);
        sb.append(HEX_CHARS[v >>> 4]);
        sb.append(HEX_CHARS[v & 15]);
    }
}

Related

  1. appendHex(StringBuilder bld, byte b)
  2. appendHex(StringBuilder buf, int value, int width)
  3. appendHex(StringBuilder buff, int i)
  4. appendHex(StringBuilder builder, int b)
  5. appendHexByte(byte b, StringBuffer buf)
  6. appendHexBytes(StringBuilder builder, byte[] bytes)
  7. appendHexDumpRowPrefix(StringBuilder dump, int row, int rowStartIndex)
  8. appendHexEntity(final StringBuilder out, final char value)
  9. appendHexEscape(StringBuilder out, int codePoint)