Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    static byte[] hexStringToByteArray(String hexString) {
        int resultLen = hexString.length() / 2;
        byte[] result = new byte[resultLen];
        for (int i = 0; i < resultLen; i++) {
            result[i] = (byte) ((Character.digit(hexString.charAt(i * 2), 16) << 4)
                    + Character.digit(hexString.charAt((i * 2) + 1), 16));
        }
        return result;
    }
}