Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String toHex(byte[] to) {
        if (null == to || to.length == 0)
            return "[]";
        StringBuffer sb = new StringBuffer("[" + Integer.toHexString(to[0] & 0xFF));
        for (int i = 1; i < to.length; i++) {
            sb.append(String.format(" %02x", to[i] & 0xFF));
        }
        sb.append("]");
        return sb.toString();
    }
}