Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static char byte2char(byte b, boolean upper) throws NumberFormatException {
        if (b >= 0 && b <= 9) {
            return (char) (b + 0x30);
        } else if (b >= 10 && b <= 15) {
            if (upper) {
                return (char) (b + 0x37);
            } else {
                return (char) (b + 0x57);
            }
        }
        throw new NumberFormatException("unknown byte: " + b);
    }
}