Here you can find the source of toText(ByteBuffer data, StringBuilder result, int cnt)
Parameter | Description |
---|---|
data | a parameter |
result | a parameter |
cnt | a parameter |
private static void toText(ByteBuffer data, StringBuilder result, int cnt)
//package com.java2s; import java.nio.ByteBuffer; public class Main { /**/*from ww w.j a va 2 s .c o m*/ * Gets last <tt>cnt</tt> read bytes from the <tt>data</tt> buffer and puts into <tt>result</tt> buffer in special * format: * <ul> * <li>if byte represents char from partition 0x1F to 0x80 (which are normal ascii chars) then it's put into buffer as * it is</li> * <li>otherwise dot is put into buffer</li> * </ul> * * @param data * @param result * @param cnt */ private static void toText(ByteBuffer data, StringBuilder result, int cnt) { int charPos = data.position() - cnt; for (int a = 0; a < cnt; a++) { int c = data.get(charPos++); if (c > 0x1f && c < 0x80) result.append((char) c); else result.append('.'); } } }