Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static String[] HEXS = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C",
            "D", "E", "F" };

    @Deprecated
    public static String toHexString(byte[] content, int len) {
        if (content == null || content.length == 0) {
            return "";
        }
        if (len > content.length) {
            len = content.length;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < len; i++) {
            int c = content[i];
            c &= 0xFF;
            sb.append(' ').append(HEXS[c / 16]).append(HEXS[c % 16]);
        }
        sb.deleteCharAt(0);
        return sb.toString();
    }

    @Deprecated
    public static String toHexString(byte[] content) {
        if (content == null) {
            return "";
        }
        return toHexString(content, content.length);
    }
}