Here you can find the source of readFromBuffer(byte[] buffer, int start, int end)
Parameter | Description |
---|---|
buffer | the byte buffer |
start | the index from which to start reading |
end | the index at which to stop reading |
public static String readFromBuffer(byte[] buffer, int start, int end)
//package com.java2s; // https://github.com/Talend/data-prep/blob/master/LICENSE import java.nio.ByteBuffer; import java.nio.charset.Charset; public class Main { /**/*from w w w . j av a2 s. c o m*/ * ASCII charset used to detect CSV and Html formats */ public static final Charset ASCII = Charset.forName("US-ASCII"); /** * Returns a string read from a buffer of bytes after replacing null character by the empty string. * * @param buffer the byte buffer * @param start the index from which to start reading * @param end the index at which to stop reading * @return a string read from a buffer of bytes after replacing null character by the empty string */ public static String readFromBuffer(byte[] buffer, int start, int end) { String result = ASCII.decode(ByteBuffer.wrap(buffer, start, end)).toString(); Character c = Character.MIN_CODE_POINT; result = result.replaceAll(c.toString(), ""); return result; } }