Here you can find the source of toAscii(byte[] b)
public static String toAscii(byte[] b)
//package com.java2s; //License from project: Open Source License public class Main { public static String toAscii(byte[] b) { StringBuffer s = new StringBuffer(); if (b == null) { return ""; }//from ww w . j av a 2s . c o m for (int i = 0; i < b.length; i++) { if (b[i] != 0) { char in = (char) b[i]; s.append(in); } } return s.toString(); } }