Here you can find the source of toAsciiString(byte[] buffer, int startPos, int length)
public static final String toAsciiString(byte[] buffer, int startPos, int length)
//package com.java2s; //License from project: Apache License public class Main { public static final String toAsciiString(byte[] buffer, int startPos, int length) { char[] charArray = new char[length]; int readpoint = startPos; for (int i = 0; i < length; i++) { charArray[i] = (char) buffer[readpoint]; readpoint++;//from w ww .j a va 2s .c om } return new String(charArray); } public static final String toAsciiString(byte[] buffer) { return toAsciiString(buffer, 0, buffer.length); } }