Java examples for java.lang:byte Array to String
byte Array To Hex String No Spacing
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { byte[] b = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(byteArrayToHexStringNoSpacing(b)); }// w ww .j a v a 2 s . co m public static String byteArrayToHexStringNoSpacing(byte[] b) { StringBuffer sb = new StringBuffer(b.length * 4); for (int i = 0; i < b.length; i++) { int v = b[i] & 0xff; if (v < 16) { sb.append('0'); } sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(); } }