import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; class Program01 { public static void main(String[] args) throws IOException { CopyFile.copyFile("eredeti.txt", "masolat2.txt"); } } class CopyFile { public static void copyFile(String srcFile, String desFile) { java.io.File inFile = new java.io.File(srcFile); java.io.File outFile = new java.io.File(desFile); FileReader in = null; FileWriter out = null; try { in = new FileReader(inFile); }catch(java.io.FileNotFoundException e){ System.err.println("A fájl nem található!"); System.exit(0); } try { out = new FileWriter(outFile); int c; while ((c = in.read()) != -1) out.write(c); System.out.println("Másolás kész."); } catch(java.io.IOException e) { System.err.println("Ki- beviteli hiba!"); } finally { try { in.close(); out.close(); }catch(java.io.IOException e){} } } }