import java.io.*; public class RandAccessFile{ public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter File name : "); String str = in.readLine(); File file = new File(str); if(!file.exists()) { System.out.println("File does not exist."); System.exit(0); } try{ //Open the file for both reading and writing RandomAccessFile rand = new RandomAccessFile(file,"rw"); rand.seek(file.length()); //Seek to end of file rand.writeBytes("Roseindia.net,"); //Write end of file rand.close(); System.out.println("Write Successfully"); } catch(IOException e) { System.out.println(e.getMessage()); } } }