Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static byte[] stringToBytes(String in) {

        int length = in.length() / 2;

        byte[] b = new byte[length];

        for (int i = 0; i < length; i++) {
            b[i] = Integer.valueOf(in.substring(i * 2, i * 2 + 2), 16).byteValue();
        }

        return b;
    }
}