Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.ByteArrayInputStream;

import java.io.IOException;

import java.nio.ByteBuffer;

public class Main {
    public static int byteArrayCompare(byte[] byte1, byte[] byte2) {
        byte[] tByte1 = new byte[byte2.length];

        ByteArrayInputStream input = new ByteArrayInputStream(byte1);

        try {
            input.read(tByte1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        ByteBuffer byteBuf1 = ByteBuffer.wrap(tByte1);
        ByteBuffer byteBuf2 = ByteBuffer.wrap(byte2);

        return byteBuf1.compareTo(byteBuf2);
    }
}