Example usage for java.io BufferedReader read

List of usage examples for java.io BufferedReader read

Introduction

In this page you can find the example usage for java.io BufferedReader read.

Prototype

public int read(java.nio.CharBuffer target) throws IOException 

Source Link

Document

Attempts to read characters into the specified character buffer.

Usage

From source file:carnero.cgeo.cgBase.java

private void readIntoBuffer(BufferedReader br, StringBuffer buffer) throws IOException {
    int bufferSize = 1024 * 16;
    char[] bytes = new char[bufferSize];
    int bytesRead;
    while ((bytesRead = br.read(bytes)) > 0) {
        if (bytesRead == bufferSize) {
            buffer.append(bytes);//ww w. j  ava  2  s .c om
        } else {
            buffer.append(bytes, 0, bytesRead);
        }
    }
}

From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java

public int SysReadFile(TaskQualification taskView, int file, StringBuilder sbReturnBuffer, int bufferLth)
        throws IOException {
    BufferedReader reader = getReaderFromInt(taskView.getTask(), file);
    char[] line = new char[bufferLth];
    int charsRead = reader.read(line);
    sbReturnBuffer.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer.
    sbReturnBuffer.append(line, 0, charsRead);
    return charsRead;
}