Java InputStream Copy to File copyStreamIntoFile(File outFile, InputStream is)

Here you can find the source of copyStreamIntoFile(File outFile, InputStream is)

Description

copy Stream Into File

License

Open Source License

Declaration

public static void copyStreamIntoFile(File outFile, InputStream is) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static void copyStreamIntoFile(File outFile, InputStream is) throws IOException {
        OutputStream os = new FileOutputStream(outFile);

        byte[] buf = new byte[1024];
        int len;/*ww w .  j a va2s  . co m*/
        while ((len = is.read(buf)) > 0) {
            os.write(buf, 0, len);
        }

        is.close();
        os.close();
    }
}

Related

  1. copyStream(final InputStream in, final File dest)
  2. copyStream(final InputStream is, final File destinationFile)
  3. copyStream(InputStream copyFrom, File copyTo)
  4. copyStream(InputStream in, File dest)
  5. copyStream(InputStream in, File dest)
  6. copyStreamsToFile(String path, Map streamMap)
  7. copyStreamsToFolder(Iterator> streams, File folder)
  8. copyStreamToFile(final File to, final InputStream from)
  9. copyStreamToFile(InputStream from, File to)