CopyFile

Aus Programmers Guide

Wechseln zu: Navigation, Suche
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