Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static final String bytesToHexString(byte[] bArray) {
        StringBuffer sb = null;
        String sTemp;

        if (bArray == null || bArray.length <= 0) {
            return null;
        }
        sb = new StringBuffer(bArray.length);
        for (int i = 0; i < bArray.length; i++) {
            sTemp = Integer.toHexString(0xFF & bArray[i]);
            if (sTemp.length() < 2)
                sb.append(0);
            sb.append(sTemp.toUpperCase());
        }
        return sb.toString();
    }
}