Java FileOutputStream Write SaveFileFromInputStream(InputStream stream, String path, String filename)

Here you can find the source of SaveFileFromInputStream(InputStream stream, String path, String filename)

Description

Save File From Input Stream

License

Open Source License

Declaration

public static void SaveFileFromInputStream(InputStream stream, String path, String filename)
        throws IOException 

Method Source Code

//package com.java2s;

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

public class Main {

    public static void SaveFileFromInputStream(InputStream stream, String path, String filename)
            throws IOException {
        FileOutputStream fs = new FileOutputStream(path + "/" + filename);
        byte[] buffer = new byte[1024 * 1024];
        int byteread = 0;
        while ((byteread = stream.read(buffer)) != -1) {
            fs.write(buffer, 0, byteread);
            fs.flush();//w ww  . j  av  a 2  s  .  c o  m
        }
        fs.close();
        stream.close();
    }
}

Related

  1. saveFile(String pathname, String fileName, String contents)
  2. saveFile(String pathRoot, String subPath, boolean isFoler, InputStream in)
  3. saveFile(String text, File saveFile)
  4. saveFileBinary(final File file, final byte[] data)
  5. SaveFileFromInputStream(InputStream in, String fileName, String path)
  6. saveInFile(String filename, String content, String charsetName)
  7. saveInputStream(InputStream _input_stream, File _file)
  8. saveInputStream(InputStream is, String filePath)
  9. saveInt16bit(String filename, int[] intData)