Java BufferedReader Read All ReadAll_Variant2(Reader rd, Writer wr)

Here you can find the source of ReadAll_Variant2(Reader rd, Writer wr)

Description

Read Al Variant

License

Open Source License

Declaration

private static void ReadAll_Variant2(Reader rd, Writer wr) throws Exception 

Method Source Code


//package com.java2s;
/*// w ww .  java  2  s .c  o  m
 * Copyright (C) 2008-2012  Marco Guazzone
 *                          [Distributed Computing System (DCS) Group,
 *                           Computer Science Institute,
 *                           Department of Science and Technological Innovation,
 *                           University of Piemonte Orientale,
 *                           Alessandria (Italy)]
 *
 * This file is part of dcj-commons.
 *
 * dcsj-commons 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 3 of the License, or
 * (at your option) any later version.
 *
 * dcsj-commons 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with dcsj-commons.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.BufferedReader;

import java.io.PrintWriter;
import java.io.Reader;

import java.io.Writer;

public class Main {
    private static void ReadAll_Variant2(Reader rd, Writer wr) throws Exception {
        // preconditions
        if (rd == null) {
            throw new Exception("Reader not specified");
        }
        if (wr == null) {
            throw new Exception("Writer not specified");
        }

        BufferedReader brd = new BufferedReader(rd);
        PrintWriter pwr = new PrintWriter(wr);
        //java.io.PrintWriter pwr = new java.io.PrintWriter( new java.io.BufferedWriter( wr ) );

        String line = null;
        while ((line = brd.readLine()) != null) {
            pwr.println(line);
            //pwr.flush();
        }
        pwr.flush();
    }
}

Related

  1. readAll(String fileName)
  2. readAll(String filePath)
  3. readAll(String filePathAndName)
  4. readAll(String ip)
  5. readAll(String path)
  6. readAllCourseNum()
  7. readAllCoursePro()
  8. readAllCourseTime()
  9. readAllFromInputStream(InputStream inputStream)