Java FileInputStream Copy copyFileLowLevel(File source, File target)

Here you can find the source of copyFileLowLevel(File source, File target)

Description

copy File Low Level

License

Open Source License

Declaration

private static void copyFileLowLevel(File source, File target) throws FileNotFoundException, IOException 

Method Source Code

//package com.java2s;
/**/*from  www  .j  a  va 2 s  .c om*/
 * Copyright 2008 Autentia Real Business Solutions S.L.
 * 
 * This file is part of autentia-util.
 * 
 * autentia-util is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * autentia-util is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with autentia-util. If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    private static void copyFileLowLevel(File source, File target) throws FileNotFoundException, IOException {
        target.getParentFile().mkdirs();

        final InputStream is = new FileInputStream(source);
        final OutputStream os = new FileOutputStream(target);
        final byte[] buffer = new byte[65536]; // 64 KBytes de buffer
        int c;
        while ((c = is.read(buffer)) != -1) {
            os.write(buffer, 0, c);
        }
        os.close();
        is.close();
    }
}

Related

  1. copyFileBinary(String source, String destination)
  2. copyFileContents(File fromFile, File destination, boolean useTempFilenames)
  3. copyFileFolder(final File source, final File dest, final boolean override)
  4. copyFileFromFileToFile(File fromFile, File toFile)
  5. copyFileFromTo(String filename, File fromDir, File toDir)
  6. copyFileR(File srcFile, File destDirectory)
  7. copyFileRecursive(File src, File dest)
  8. copyFileToAnotherDirWithRelativePaths(File srcDir, File destDir, File originalFile)
  9. copyFileToContainer(File pChild, IContainer pContainer)