Java FileOutputStream Write saveStreamToFile(InputStream is, File destFile)

Here you can find the source of saveStreamToFile(InputStream is, File destFile)

Description

save Stream To File

License

Apache License

Declaration

public static boolean saveStreamToFile(InputStream is, File destFile) throws IOException 

Method Source Code

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

import java.io.File;

import java.io.FileOutputStream;

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

public class Main {
    public static boolean saveStreamToFile(InputStream is, File destFile) throws IOException {
        FileOutputStream fos = new FileOutputStream(destFile);
        int readLen = 0;
        byte[] buf = new byte[1024];
        while ((readLen = is.read(buf)) != -1) {
            System.out.println(readLen);
            fos.write(buf, 0, readLen);/*from  www.j  a  va  2  s .c  om*/
        }
        fos.flush();
        fos.close();
        is.close();
        return true;
    }
}

Related

  1. saveProxyClass(String path, String proxyClassName, Class[] interfaces)
  2. saveResouce(String resourceName, String outputFile)
  3. saveStream(InputStream is, File output)
  4. saveStream(InputStream stream, File targetFile)
  5. saveStreamToFile(InputStream in, File outFile)
  6. saveStringIntoFile(File file, String contents)
  7. saveStringIntoFile(String filePath, String contents)
  8. saveStringsList(String file, Collection c)
  9. saveStringToFile(File file, String content, String charset)