Inserting data "somewhere" in a sequential file would require that the entire file be rewritten. It is possible, however, to add data to the end of a file without rewriting the entire file. Adding data to the end of an existing file is called appending.

To attempt appending a file, the FileWriter class will be needed
as it can directly address appending.FileWriter(String file, boolean append)
If append is stated as true, output will be appended to the end of the existing file contents.

Notice: These materials are free for your on-line use at this site, but are not free for the taking.
Please do not copy these
materials or re-post them to the Internet, as it is copyright infringement.
If you wish hard-copies of these materials, refer to our subscription area, JavaMathBits.com.
Help us keep these resources free. Thank you.