Before writing the new data to the already existing file, place the outputstream cursor on the end of the file.
public java.io.OutputStream openOutputStream(long byteOffset)
throws java.io.IOExceptionThis method opens an output stream and positions it at the indicated byte offset in the file. Data written to the returned output stream at that position overwrites any existing data until EOF is reached, and then additional data is appended. The connection's target must already exist and be accessible for the output stream to be created.
Changes made to a file through an output stream may not be immediately made to the actual file residing on the file system because platform and implementation specific use of caching and buffering of the data. Stream contents and file length extensions are not necessarily visible outside of the application immediately unless flush() is called on the stream. The returned output stream is automatically and synchronously flushed when it is closed.
byteOffset - number of bytes to skip over from the beginning of the file when positioning the start of the OutputStream. If the provided offset is larger than or equal to the current file size, the OutputStream is positioned at the current end of the file for appending.
an open OutputStream positioned at the byte offset in the file, or the end of the file if the offset is greater than the size of the file.
java.io.IOException - If an I/O error occurs, if the method is invoked on a directory, the file does not yet exist, or the connection's target is not accessible.
IllegalModeException - if the application does have write access to the connection's target but has opened the connection in Connector.READ mode.
java.lang.SecurityException - if the security if the application does not allow write access to the file.
java.lang.IllegalArgumentException - if byteOffset has a negative value.