Here you can find the source of copyFileLowLevel(File source, File target)
private static void copyFileLowLevel(File source, File target) throws FileNotFoundException, IOException
//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(); } }