String base16 decode to byte array - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

String base16 decode to byte array

Demo Code


//package com.book2s;

public class Main {

    public static byte[] base16decode(String base16Str) {
        byte[] ret = new byte[base16Str.length() / 2];
        int j = 0;
        for (int i = 0; i < base16Str.length(); i += 2) {
            ret[j++] = (byte) (Integer.parseInt("" + base16Str.charAt(i)
                    + base16Str.charAt(i + 1), 16));
        }// www .  j ava  2s  .  co m
        return ret;
    }
}

Related Tutorials