Here you can find the source of copyFile(File fromFile, File toFile)
Parameter | Description |
---|---|
fromFile | File to be copied |
toFile | Destination File |
Parameter | Description |
---|---|
FileNotFoundException | if fromFile was not found |
IOException | if operation fails |
@Deprecated public static void copyFile(File fromFile, File toFile) throws FileNotFoundException, IOException
//package com.java2s; /*//from w w w . jav a 2 s. c om Copyright 2012 Juan Mart?n Runge jmrunge@gmail.com http://www.zirsi.com.ar This file is part of ZirUtils. ZirUtils is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ZirUtils 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 General Public License for more details. You should have received a copy of the GNU General Public License along with ZirUtils. If not, see <http://www.gnu.org/licenses/>. */ import java.io.*; public class Main { /** * Legacy method to copy a file from one location to another * * @param fromFile File to be copied * @param toFile Destination File * @throws FileNotFoundException if fromFile was not found * @throws IOException if operation fails * @deprecated */ @Deprecated public static void copyFile(File fromFile, File toFile) throws FileNotFoundException, IOException { FileOutputStream to; try (FileInputStream from = new FileInputStream(fromFile)) { to = new FileOutputStream(toFile); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = from.read(buffer)) > 0) to.write(buffer, 0, bytesRead); } to.close(); } }