Java FileOutputStream Write saveFile(InputStream is, String destDir, String fileName)

Here you can find the source of saveFile(InputStream is, String destDir, String fileName)

Description

save File

License

Apache License

Declaration

private static void saveFile(InputStream is, String destDir,
        String fileName) throws FileNotFoundException, IOException 

Method Source Code

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

import java.io.*;

public class Main {

    private static void saveFile(InputStream is, String destDir,
            String fileName) throws FileNotFoundException, IOException {
        BufferedInputStream bis = new BufferedInputStream(is);
        BufferedOutputStream bos = new BufferedOutputStream(
                new FileOutputStream(new File(destDir + fileName)));
        int len = -1;
        while ((len = bis.read()) != -1) {
            bos.write(len);//from w ww.  j av a2s  .co  m
            bos.flush();
        }
        bos.close();
        bis.close();
    }
}

Related

  1. saveFile(final File file, final byte[] dataToSave)
  2. saveFile(final File file, final String contents, final String encoding)
  3. saveFile(final InputStream in, final String path, final String fileName)
  4. saveFile(final String filename, final String s1, final String textOut, final String s3)
  5. saveFile(InputStream is, File file)
  6. savefile(InputStream source, String destination)
  7. saveFile(InputStream uploadedInputStream, String serverLocation)
  8. saveFile(String content, String path)
  9. saveFile(String desEncryptTempFile, byte[] text)