Java File Copy workaroundCopyFile(final File src, final File dest)

Here you can find the source of workaroundCopyFile(final File src, final File dest)

Description

workaround Copy File

License

Open Source License

Declaration

protected static void workaroundCopyFile(final File src, final File dest) 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.FileOutputStream;

import java.io.IOException;

public class Main {
    protected static void workaroundCopyFile(final File src, final File dest) throws IOException {
        FileInputStream from = null;
        FileOutputStream to = null;
        try {//  w w w.ja  v  a2 s .c  o m
            from = new FileInputStream(src);
            to = new FileOutputStream(dest);
            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = from.read(buffer)) != -1) {
                to.write(buffer, 0, bytesRead);
            }
        } finally {
            if (from != null) {
                try {
                    from.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (to != null) {
                try {
                    to.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. fileCopy(String oldFilePath, String newFilePath, boolean isCover)
  2. fileCopy(String sFrom, String sTo)
  3. fileCopy(String source, String target)
  4. fileCopy(String sourceFile, String destinationFile)
  5. fileCopy(String sourcefile, String destinctionFile)