Convert byte to Hex string by single statement - Android java.lang

Android examples for java.lang:Hex

Description

Convert byte to Hex string by single statement

Demo Code


//package com.java2s;

public class Main {
    public static String toHex(byte b) {
        return ("" + "0123456789ABCDEF".charAt(0xf & b >> 4) + "0123456789ABCDEF"
                .charAt(b & 0xf));/*from   w w w.  jav  a 2 s.  co m*/
    }
}

Related Tutorials