I am trying to use the AsynchronousFileChannelJAVA 7 API to write a file in an asynchronous way, however I could not find an easy way to add it to the file.
The description of the API states that it AsynchronousFileChanneldoes not support the position of the file, and you must specify the position of the file. This means that you must maintain the global value of the file position. Moreover, this global state must be atomic in order for you to increase properly.
Is there a better way to do updates using AsynchronousFileChannel?
Also, can someone explain the use of the Attachment object in the API?
public abstract <A> void write(ByteBuffer src,
long position,
A attachment,
CompletionHandler<Integer ,? super A> handler)
The javadoc says: attachment - An object to attach to an I / O operation; may be null
What is the point of using this binding object?
Thanks!