Java InputStream to File inputStreamToFile(InputStream is, File targetFile)

Here you can find the source of inputStreamToFile(InputStream is, File targetFile)

Description

input Stream To File

License

Apache License

Declaration

public static void inputStreamToFile(InputStream is, File targetFile) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

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

import com.google.common.io.ByteStreams;

public class Main {
    public static void inputStreamToFile(InputStream is, File targetFile) throws IOException {
        byte[] buffer = ByteStreams.toByteArray(is);
        OutputStream outStream = new FileOutputStream(targetFile);
        outStream.write(buffer);//from   w  w  w  .j a va2  s  . c o  m
        outStream.flush();
        outStream.close();
    }
}

Related

  1. inputStreamToFile(InputStream byteStream, String pathFileName)
  2. inputStreamToFile(InputStream in, File file)
  3. inputStreamToFile(InputStream ins, File file)
  4. inputstreamtofile(InputStream ins, File file)
  5. inputStreamToFile(InputStream is)
  6. inputStreamToFile(InputStream stream, File file)
  7. writeStreamToFile(File target, InputStream in)
  8. writeStreamToFile(InputStream _actual, File _file)
  9. writeStreamToFile(InputStream in, OutputStream out)