Here you can find the source of saveDownloadedFile(InputStream is, String destination)
Parameter | Description |
---|---|
is | Input stream |
destination | file path to be used |
Parameter | Description |
---|---|
IOException | if there is an IO error |
public static void saveDownloadedFile(InputStream is, String destination) throws IOException
//package com.java2s; //License from project: Apache License import com.google.common.io.ByteStreams; import java.io.*; public class Main { /**/*w w w. j ava 2 s . co m*/ * Saves an input stream as file * * @param is Input stream * @param destination file path to be used * @throws IOException if there is an IO error */ public static void saveDownloadedFile(InputStream is, String destination) throws IOException { BufferedOutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(new File(destination))); ByteStreams.copy(is, out); } finally { is.close(); if (out != null) { out.close(); } } } }