Here you can find the source of saveInputStream(InputStream _input_stream, File _file)
Parameter | Description |
---|---|
_input_stream | The InputStream to be saved. |
_file | The target file. |
public static String saveInputStream(InputStream _input_stream, File _file) throws IOException
//package com.java2s; //License from project: Mozilla Public License import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; public class Main { /**/* w w w. j a v a2 s . c o m*/ * Save an {@link Object} to a given filename. * @param _input_stream The InputStream to be saved. * @param _file The target file. * @return A String containing the name of the file. */ public static String saveInputStream(InputStream _input_stream, File _file) throws IOException { BufferedInputStream input_stream = new BufferedInputStream(_input_stream); BufferedOutputStream output_stream = new BufferedOutputStream(new FileOutputStream(_file)); int stream_byte; while ((stream_byte = input_stream.read()) != -1) output_stream.write(stream_byte); output_stream.flush(); input_stream.close(); return _file.getAbsolutePath(); } }