Here you can find the source of copyFile(String quelle, String ziel)
public static boolean copyFile(String quelle, String ziel)
//package com.java2s; /**//from ww w .j a v a 2 s.c o m * Title: efa - elektronisches Fahrtenbuch f?r Ruderer * Copyright: Copyright (c) 2001-2011 by Nicolas Michael * Website: http://efa.nmichael.de/ * License: GNU General Public License v2 * * @author Nicolas Michael * @version 2 */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; public class Main { public static boolean copyFile(String quelle, String ziel) { if ((new File(quelle)).equals(new File(ziel))) { return false; // Quelle und Ziel sind dieselbe Datei! } final int BUFSIZE = 4096; FileInputStream f1; FileOutputStream f2; byte[] buf = new byte[BUFSIZE]; int n; if (!canOpenFile(quelle)) { return false; } try { f1 = new FileInputStream(quelle); f2 = new FileOutputStream(ziel); while ((n = f1.read(buf, 0, BUFSIZE)) > 0) { f2.write(buf, 0, n); } f1.close(); f2.close(); } catch (IOException e) { return false; } return true; } public static boolean canOpenFile(String d) { FileReader f; try { f = new FileReader(d); f.close(); } catch (Exception e) { return false; } return true; } }