File infile = new File(file1);
File outfile = new File(file2);
if (infile.getCanonicalPath().equals(outfile.getCanonicalPath())) {
return;
}
FileReader fr = new FileReader(infile);
FileWriter fw = new FileWriter(outfile);
while (true) {
int i = fr.read();
if (i == -1) break;
fw.write(i);
}
fw.close();
fr.close();