Here you can find the source of copyFileToFile(File file, File outFile)
Parameter | Description |
---|---|
file | a parameter |
outFile | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
FileNotFoundException | an exception |
public static void copyFileToFile(File file, File outFile) throws IOException, FileNotFoundException
//package com.java2s; import java.io.*; public class Main { /**// ww w . j av a 2 s. c o m * Copy a file to a location given by another file. * This makes a backup implicity * @param file * @param outFile * @throws IOException * @throws FileNotFoundException */ public static void copyFileToFile(File file, File outFile) throws IOException, FileNotFoundException { FileInputStream in = new FileInputStream(file); FileOutputStream out = new FileOutputStream(outFile); byte[] buf = new byte[512]; int l; try { while ((l = in.read(buf)) > 0) { out.write(buf, 0, l); } out.flush(); } catch (IOException e) { throw e; } finally { try { out.close(); } catch (Exception ignored) { } try { in.close(); } catch (Exception ignored) { } } } }