提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
字节到十六进制
/** 来 自 nowjava **/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { byte someByte = 2; System.out.println(java.util.Arrays.toString(byteToHex(someByte))); } private final static char[] hexArray = "0123456789ABCDEF".toCharArray(); public static char[] byteToHex(byte someByte) { char[] hexChars = new char[2]; int v = someByte & 0xF