Java FileInputStream Copy copyFile(File file, OutputStream os)

Here you can find the source of copyFile(File file, OutputStream os)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File file, OutputStream os) throws IOException 

Method Source Code


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

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    public static void copyFile(File file, OutputStream os) throws IOException {
        final int buffersize = 4096;

        FileInputStream fis = new FileInputStream(file);
        try {/*from w w w . ja v a  2s. com*/
            byte[] buf = new byte[buffersize];
            int count;

            while ((count = fis.read(buf, 0, buffersize)) != -1) {
                os.write(buf, 0, count);
            }
        } finally {
            fis.close();
        }
    }
}

Related

  1. copyFile(File destination, File source)
  2. copyFile(File existingFile, File destFile)
  3. copyFile(File file, File destPath)
  4. copyFile(File file, File dir)
  5. copyFile(File file, File newFile, boolean overwrite, boolean setLastModified)
  6. copyFile(File fileSrc, File fileDest)
  7. copyFile(File fileToCopy, File targetDir)
  8. copyFile(File from, File to)
  9. copyFile(File from, File to)