Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static String getHexStr(byte[] b) {
        StringBuilder builder = new StringBuilder();
        ByteArrayInputStream input = new ByteArrayInputStream(b);
        int i = 0;
        while ((i = input.read()) != -1) {
            builder.append(
                    Integer.toHexString(i).length() == 2 ? Integer.toHexString(i) : 0 + Integer.toHexString(i));
            builder.append(" ");
        }
        return builder.toString();
    }
}