Java Hex String Create appendHexNumber(StringBuffer target, byte b)

Here you can find the source of appendHexNumber(StringBuffer target, byte b)

Description

append Hex Number

License

Open Source License

Declaration

public static void appendHexNumber(StringBuffer target, byte b) 

Method Source Code

//package com.java2s;
/*/*ww w .j a  v a 2  s  .  c o m*/
 * ====================================================================
 * Copyright (c) 2004-2012 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://svnkit.com/license.html
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

public class Main {
    private static char[] HEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    public static void appendHexNumber(StringBuffer target, byte b) {
        int lo = b & 0xf;
        int hi = (b >> 4) & 0xf;
        target.append(HEX[hi]);
        target.append(HEX[lo]);
    }
}

Related

  1. appendHexBytes(StringBuilder builder, byte[] bytes)
  2. appendHexDumpRowPrefix(StringBuilder dump, int row, int rowStartIndex)
  3. appendHexEntity(final StringBuilder out, final char value)
  4. appendHexEscape(StringBuilder out, int codePoint)
  5. appendHexJavaScriptRepresentation(StringBuilder sb, char c)
  6. appendHexPair(byte b, StringBuffer sb)
  7. appendHexStream(StringBuilder sb, byte[] bytes, String delimiter, boolean prefixEachValue, boolean upperCase)
  8. appendHexString(StringBuffer buffer, byte data)
  9. appendHexString(StringBuilder buffer, byte[] bytes)