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[] toFormattedByteArray(String baseString) {
        return toFormattedByteArray(baseString.getBytes());
    }

    public static byte[] toFormattedByteArray(byte[] baseArray) {
        int length = baseArray.length;
        byte[] byteArray = new byte[length + 1];

        byteArray[0] = (byte) length;
        for (int i = 0; i < length; i++) {
            byteArray[i + 1] = baseArray[i];
        }

        return byteArray;
    }
}