Java Byte to Hex byteToHex(final byte b, StringBuilder buffer)

Here you can find the source of byteToHex(final byte b, StringBuilder buffer)

Description

byte To Hex

License

Open Source License

Declaration

static void byteToHex(final byte b, StringBuilder buffer) 

Method Source Code

//package com.java2s;
/**/*  www  .j  a v  a  2 s. com*/
 * Copyright (c) 2013-2014 Santiago M. Mola <santi@mola.io>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

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

    static void byteToHex(final byte b, StringBuilder buffer) {
        int i = b & 0xFF;
        buffer.append(_hex[i >>> 4]);
        buffer.append(_hex[i & 0x0F]);
    }
}

Related

  1. byteToHex(byte[] bytes)
  2. byteToHex(byte[] data)
  3. byteToHex(char val)
  4. byteToHex(final byte b)
  5. byteToHex(final byte b)
  6. byteToHex(final byte value)
  7. byteToHex(final byte value, final int minLength)
  8. byteToHex(final byte[] data)
  9. byteToHex(int v)