import java.io.FileWriter; import java.io.IOException; public class Program01 { public static void writeFile() { FileWriter fw = null; try { fw = tryFajlbaIr(); } catch(IOException ex) { System.err.println("Hiba a fájlbaírás során!"); } finally { try { fw.close(); } catch(IOException ex) { System.err.println("Hiba a fájl bezárása során!"); } } } public static FileWriter tryWriteFile() throws IOException { FileWriter fw = new FileWriter("adat.txt", true); fw.write("alma"); return fw; } public static void main (String args[]) { writeFile(); } }