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 encodeHexString(byte[] bytes) {
        StringBuilder buffer = new StringBuilder();
        encodeHexString(bytes, buffer);
        return buffer.toString();
    }

    public static void encodeHexString(byte[] bytes, StringBuilder buffer) {
        for (byte b : bytes) {
            int hi = (b >>> 4) & 0x0f;
            int lo = (b >>> 0) & 0x0f;
            buffer.append(Character.forDigit(hi, 16));
            buffer.append(Character.forDigit(lo, 16));
        }
    }
}