目前项目中使用字节流处理一些事务,比如保存图片,保存文件都转化为网络字节来存取,感觉不错,分享下。 /** 十六进制的数字 */ private static final String[] HEX_DIGITS = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; pubilc static String byteToHexString(byte b) { int n = b; if (n < 0) { n = FIX_NUMBER256 + n; } int d1 = n / FIX_NUMBER16; int d2 = n % FIX_NUMBER16; return HEX_DIGITS[d1] + HEX_DIGITS[d2]; }