Convert binary byte array To Hex - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert binary byte array To Hex

Demo Code

/*/*from  www  .  j  av 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 binaryToHex(byte[] bytes) {
        StringBuilder sb = new StringBuilder(2 * bytes.length);
        for (byte b : bytes) {
            sb.append(String.format("%02x", b & 0xff));
        }
        return sb.toString();
    }
}

Related Tutorials