Convert byte array to Hex String via Formatter - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert byte array to Hex String via Formatter

Demo Code


//package com.java2s;

import java.util.Formatter;

public class Main {
    private static String toHexString(byte[] bytes) {
        Formatter formatter = new Formatter();

        for (byte b : bytes) {
            formatter.format("%02x", b);
        }/*from ww w . j a  v  a2 s.  c o  m*/

        return formatter.toString();
    }
}

Related Tutorials