Java Dump Stream dumpStream(InputStream in, String file)

Here you can find the source of dumpStream(InputStream in, String file)

Description

Dump stream to file

License

Open Source License

Declaration

public static void dumpStream(InputStream in, String file) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    /** Dump stream to file */
    public static void dumpStream(InputStream in, String file) {
        try {/*from  w  w w . j  a  v  a 2s  .co m*/
            File f = new File(file);

            OutputStream os = new FileOutputStream(f);
            int ch;
            while ((ch = in.read()) >= 0)
                os.write(ch);

            os.flush();
            os.close();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

  1. dumpInputStream(InputStream stream)
  2. dumpInputStreamAsString(InputStream is)
  3. dumpInputStreamIntoString(InputStream f, String encoding)
  4. dumpMap(PrintStream out, Map Values)
  5. dumpStream(InputStream in, PrintStream dump, boolean closeIn)
  6. dumpStreamAndReOffer(InputStream is)
  7. dumpStreamToFile(InputStream is, String filename)
  8. dumpStreamToStream(InputStream is, OutputStream os)
  9. dumpThreads(PrintStream ps)