Java Dump Stream dumpFile(InputStream file, String header, String testName)

Here you can find the source of dumpFile(InputStream file, String header, String testName)

Description

dump File

License

Open Source License

Declaration

protected static void dumpFile(InputStream file, String header, String testName) throws IOException 

Method Source Code


//package com.java2s;
/*/*from  ww  w.  j  av  a 2 s  . c o m*/
 * Copyright 2008-2009 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code 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
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */

import java.io.*;

public class Main {
    protected static void dumpFile(InputStream file, String header, String testName) throws IOException {
        dumpFile(System.out, file, header, testName);
    }

    protected static void dumpFile(PrintStream output, InputStream file, String header, String testName)
            throws IOException {
        output.println("--" + header + " for " + testName + "--");
        BufferedReader reader = new BufferedReader(new InputStreamReader(file));
        try {
            while (true) {
                String line = reader.readLine();
                if (line == null)
                    break;
                output.println(line);
            }
        } finally {
            reader.close();
        }
    }
}

Related

  1. dump(InputStream is, File to)
  2. dump(PrintStream p, String indent, String s)
  3. dumparr(Object[] arr, PrintStream out, boolean term)
  4. dumpArray(PrintStream out, Object[] array)
  5. dumpEvent(String event, OutputStream stream)
  6. dumpFile(JarInputStream jin, File targetFile)
  7. dumpFile(String r_file, OutputStream outputstream)
  8. dumpInputOutputStream(InputStream is, OutputStream os)
  9. dumpInputStream(InputStream instream)