Java Reader Read loadReader(final Reader in, final StringBuffer buffer)

Here you can find the source of loadReader(final Reader in, final StringBuffer buffer)

Description

Reads contents of a Reader into a string buffer.

License

Open Source License

Parameter

Parameter Description
in This reader will be loaded.
buffer Buffer to fill with file contents.

Exception

Parameter Description
IOException File exception occurred.

Declaration

public static void loadReader(final Reader in, final StringBuffer buffer) throws IOException 

Method Source Code

//package com.java2s;
/* This file is part of the project "Hilbert II" - http://www.qedeq.org
 *
 * Copyright 2000-2013,  Michael Meyling <mime@qedeq.org>.
 *
 * "Hilbert II" is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *///from   w  w w. j a  va2s . c o m

import java.io.IOException;

import java.io.Reader;

public class Main {
    /**
     * Reads contents of a {@link Reader} into a string buffer. Reader is not closed.
     *
     * @param   in          This reader will be loaded.
     * @param   buffer      Buffer to fill with file contents.
     * @throws  IOException File exception occurred.
     */
    public static void loadReader(final Reader in, final StringBuffer buffer) throws IOException {

        buffer.setLength(0);
        int c;
        while ((c = in.read()) >= 0) {
            buffer.append((char) c);
        }
    }
}

Related

  1. getReaderContentAsString(Reader reader)
  2. getReaderContents(Reader reader)
  3. load(InputStream input, int bufsize)
  4. loadChars(Reader in)
  5. loadFully(String path)
  6. loadReader(java.io.Reader in)
  7. loadResAsString(String res)
  8. loadText(Reader reader, int length)