Here you can find the source of loadReader(final Reader in, final StringBuffer buffer)
Parameter | Description |
---|---|
in | This reader will be loaded. |
buffer | Buffer to fill with file contents. |
Parameter | Description |
---|---|
IOException | File exception occurred. |
public static void loadReader(final Reader in, final StringBuffer buffer) throws IOException
//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); } } }