Java Hex Calculate toHexByte(byte b, StringBuffer sb)

Here you can find the source of toHexByte(byte b, StringBuffer sb)

Description

to Hex Byte

License

BSD License

Declaration

public static void toHexByte(byte b, StringBuffer sb) 

Method Source Code

//package com.java2s;
//The contents of this file are subject to the "Simplified BSD License" (the "License");

public class Main {
    public static void toHexByte(byte b, StringBuffer sb) {
        int n1 = (b & 0xF0) >> 4;
        int n2 = (b & 0xF);
        sb.append((char) (n1 < 10 ? n1 + '0' : (n1 - 10) + 'A'));
        sb.append((char) (n2 < 10 ? n2 + '0' : (n2 - 10) + 'A'));

    }/*from   w ww .  j a v a  2s  .c o  m*/
}

Related

  1. toHexadecimealString(byte[] data, int length, boolean uppercase)
  2. toHexArray(byte[] binary)
  3. toHexaString(byte[] data)
  4. toHexaString(int value)
  5. toHexByte(byte b)
  6. toHexByte(final char ch1, final char ch2)
  7. toHexByte(int bite)
  8. toHexByte(int i)
  9. toHexByteArray(final byte[] buffer)