// ------------------------------------------------------------
import java.io.*;

public class FileAppender {
  public static void main (String [] args) throws IOException { 
    // Write out part of a file
    FileWriter out = new FileWriter("Square.java");
    out.write("public class Square {\n");
    out.write("  public static float square (float x) {\n");
    out.close();

    RandomAccessFile raf = new RandomAccessFile("Square.java", "rw");
    raf.seek(raf.length());  // This is the jump to EOF

    // Now write out the remainder
    raf.writeChars("    return x * x;\n");
    raf.writeChars("  }\n");
    raf.writeChars("}\n");
    raf.close();
  }
}



