Java File Copy fileCopy(String source, String target)

Here you can find the source of fileCopy(String source, String target)

Description

file Copy

License

Open Source License

Declaration

public static void fileCopy(String source, String target) throws IOException 

Method Source Code


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

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    public static void fileCopy(String source, String target) throws IOException {
        try (InputStream in = new FileInputStream(source)) {
            try (OutputStream out = new FileOutputStream(target)) {
                byte[] buffer = new byte[4096];
                int bytesToRead;
                while ((bytesToRead = in.read(buffer)) != -1) {
                    out.write(buffer, 0, bytesToRead);
                }/*  w  ww .j a  va 2 s  . c  om*/
            }
        }
    }
}

Related

  1. fileCopy(String from, String to)
  2. fileCopy(String from, String to)
  3. fileCopy(String fromPath, String toPath)
  4. fileCopy(String oldFilePath, String newFilePath, boolean isCover)
  5. fileCopy(String sFrom, String sTo)
  6. fileCopy(String sourceFile, String destinationFile)
  7. fileCopy(String sourcefile, String destinctionFile)
  8. workaroundCopyFile(final File src, final File dest)