Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] hexToBytes(String s) {
        int length = s.length();
        byte[] data = new byte[length / 2];

        for (int index = 0; index < length; index += 2) {
            data[index / 2] = (byte) ((Character.digit(s.charAt(index), 16) << 4)
                    + Character.digit(s.charAt(index + 1), 16));
        }
        return data;
    }
}