Convert byte To Hex by String.format - Android java.lang

Android examples for java.lang:Hex

Description

Convert byte To Hex by String.format

Demo Code

/*//w w w  .  ja  v a  2 s. c  o m
 ByteUtil.java
 Copyright (c) 2016 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
//package com.java2s;

public class Main {
    public static String byteToHex(byte b) {
        return String.format("%02x", b & 0xff);
    }
}

Related Tutorials