import java.io.*; public class PripisovaniNaKonec extends RandomAccessFile { public PripisovaniNaKonec(File file) throws IOException { super(file, "rw"); seek(length()); } public PripisovaniNaKonec(String name) throws IOException { super(name, "rw"); seek(length()); } public static void main(String[] argv) throws IOException { String nl = System.getProperty("line.separator"); // prvni zapis File f = new File("a.txt"); PripisovaniNaKonec fk1 = new PripisovaniNaKonec(f); for (int i = 1; i < 10; i++) { String radka = new String(i + ". ahoj" + nl); fk1.writeBytes(radka); } fk1.close(); // druhy zapis - jiny konstruktor PripisovaniNaKonec fk2 = new PripisovaniNaKonec("a.txt"); for (int i = 20; i < 30; i++) { String radka = new String(i + ". ahoj" + nl); fk2.writeBytes(radka); } fk2.close(); } } Toto je jeho vystup: 1. ahoj 2. ahoj 3. ahoj 4. ahoj 5. ahoj 6. ahoj 7. ahoj 8. ahoj 9. ahoj 20. ahoj 21. ahoj 22. ahoj 23. ahoj 24. ahoj 25. ahoj 26. ahoj 27. ahoj 28. ahoj 29. ahoj