import java.io.FileWriter; import java.io.IOException; class FileHandler { public void writeFile() { try { tryWriteFile(); } catch (IOException e) { System.err.println("Hiba! A fájlbaírás sikertelen!"); System.err.println(e.getMessage()); } } public void tryWriteFile() throws IOException { FileWriter fw = new FileWriter("adat.txt", true); fw.write("bármi\n"); fw.close(); } } class App { public static void main(String args[]) throws Exception { new FileHandler().writeFile(); } }