Here you can find the source of toHexString3(byte aByte)
public static String toHexString3(byte aByte)
//package com.java2s; /*// ww w .j ava 2s. c om * This file is part of the NetFef serial network bus protocol project. * * Copyright (c) 2015. * Author: Balazs Kelemen * Contact: prampec+netfef@gmail.com * * This product is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. * Please contact the author for a special agreement in case you want to use this creation for commercial purposes! */ public class Main { public static String toHexString3(byte aByte) { String str = Integer.toHexString(byteToInt(aByte)); String s = str.length() == 1 ? "0x0" + str : "0x" + str; return s; } public static String toHexString(byte aByte) { String str = Integer.toHexString(byteToInt(aByte)); String s = str.length() == 1 ? "0" + str : str; if ((aByte >= ' ') && (aByte <= '~')) { s = s + "(" + (char) aByte + ")"; } return s; } public static int byteToInt(byte aByte) { return aByte & 0xFF; } }