CopyFile

Aus Programmers Guide

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
Roy (Diskussion | Beiträge)
(Die Seite wurde neu angelegt: „public static boolean copyFile(String fileIn,String fileOut) { try {<br> File f1 = new File(fileIn);<br> File f2 = new File(fileOut);<br> InputStream in = new Fi…“)
Zum nächsten Versionsunterschied →

Version vom 07:16, 30. Mär. 2010

public static boolean copyFile(String fileIn,String fileOut) {

try {
File f1 = new File(fileIn);
File f2 = new File(fileOut);
InputStream in = new FileInputStream(f1);
OutputStream out = new FileOutputStream(f2);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
return true;
} catch (FileNotFoundException ex) {
return false;
} catch (IOException e) {
return false;
}

}

Persönliche Werkzeuge