Java Hex String Create appendHex(StringBuffer buf, int x)

Here you can find the source of appendHex(StringBuffer buf, int x)

Description

append Hex

License

Open Source License

Declaration

public static void appendHex(StringBuffer buf, int x) 

Method Source Code

//package com.java2s;
/*/* w  ww  . j  a  va  2s .  com*/
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

public class Main {
    public static void appendHex(StringBuffer buf, int x) {
        appendHexChar(buf, (x >> 4) & 0x0f);
        appendHexChar(buf, x & 0x0f);
    }

    public static void appendHexChar(StringBuffer buf, int x) {
        if (x >= 10)
            buf.append((char) ('a' + x - 10));
        else
            buf.append((char) ('0' + x));
    }
}

Related

  1. appendHex(final StringBuffer buf, final byte i)
  2. appendHex(final StringBuffer buf, final int i)
  3. appendHex(int color, StringBuffer buffer)
  4. appendHex(StringBuffer buffer, byte b)
  5. appendHex(StringBuffer buffer, int value)
  6. appendHex(StringBuffer sb, byte b)
  7. appendHex(StringBuffer sbuf, char ch)