Java InputStream to File writeStreamToFile(InputStream _actual, File _file)

Here you can find the source of writeStreamToFile(InputStream _actual, File _file)

Description

write Stream To File

License

Open Source License

Declaration

public static void writeStreamToFile(InputStream _actual, File _file)
            throws FileNotFoundException, IOException 

Method Source Code


//package com.java2s;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import java.io.IOException;
import java.io.InputStream;

import java.io.OutputStream;

public class Main {
    public static void writeStreamToFile(InputStream _actual, File _file)
            throws FileNotFoundException, IOException {
        final OutputStream expected = new BufferedOutputStream(new FileOutputStream(_file));
        try {//from   www  .j  a  v  a2  s.c  o  m
            int red;
            while ((red = _actual.read()) >= 0)
                expected.write(red);
        } finally {
            expected.close();
        }
    }
}

Related

  1. inputstreamtofile(InputStream ins, File file)
  2. inputStreamToFile(InputStream is)
  3. inputStreamToFile(InputStream is, File targetFile)
  4. inputStreamToFile(InputStream stream, File file)
  5. writeStreamToFile(File target, InputStream in)
  6. writeStreamToFile(InputStream in, OutputStream out)
  7. writeStreamToFile(InputStream in, String fileName)
  8. writeStreamToFile(InputStream inputStream, File file)
  9. writeStreamToFile(InputStream inputStream, File targetFile)