Java FileOutputStream Write SaveFileFromInputStream(InputStream in, String fileName, String path)

Here you can find the source of SaveFileFromInputStream(InputStream in, String fileName, String path)

Description

Save File From Input Stream

License

Apache License

Declaration

public static void SaveFileFromInputStream(InputStream in,
        String fileName, String path) 

Method Source Code

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

import java.io.FileOutputStream;

import java.io.InputStream;

public class Main {

    public static void SaveFileFromInputStream(InputStream in,
            String fileName, String path) {
        try {/* w  w w  .  jav a  2  s . c  o  m*/
            FileOutputStream fs = new FileOutputStream(path + fileName);
            byte[] buffer = new byte[1024 * 1024];
            int bytesum = 0;
            int byteread = 0;
            while ((byteread = in.read(buffer)) != -1) {
                bytesum += byteread;
                fs.write(buffer, 0, byteread);
                fs.flush();
            }
            fs.close();
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

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