Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.io.RandomAccessFile;

public class Main {
    public static void main(String[] argv) throws Exception {
        File f = new File("filename");
        RandomAccessFile raf = new RandomAccessFile(f, "rw");

        // Read a character
        char ch = raf.readChar();

        // Seek to end of file
        raf.seek(f.length());

        // Append to the end
        raf.writeChars("aString");
        raf.close();
    }
}