Java tutorial
//package com.java2s; public class Main { public static String get_recv_data_str(byte[] rcv_buff, int len) { int i; StringBuffer sb = new StringBuffer(); for (i = 0; i < len; i++) { if ((0x00f0 & ((char) rcv_buff[i])) == 0) sb.append(0); sb.append(Integer.toHexString(0x00ff & ((char) rcv_buff[i])).toUpperCase()); // if((i+1)%16 == 0) sb.append("\r\n"); } String s = sb.toString(); return s; } }