public class FileWrite extends AsynchronousFileStep
AsynchronousFileChannel
.AsynchronousChannelStep.ChannelCallback<V,C extends java.nio.channels.AsynchronousChannel>, AsynchronousChannelStep.ChannelOperation<C extends java.nio.channels.AsynchronousChannel>
FILE_CHANNEL, FILE_POSITION
CHANNEL_GROUP
Constructor and Description |
---|
FileWrite(java.util.function.Function<Continuation<?>,java.nio.channels.AsynchronousFileChannel> fGetFileChannel)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
performAsyncOperation(int nBytesWritten,
java.nio.channels.AsynchronousFileChannel rChannel,
java.nio.ByteBuffer rData,
AsynchronousChannelStep.ChannelCallback<java.lang.Integer,java.nio.channels.AsynchronousFileChannel> rCallback)
Implementation of the ChannelOperation functional interface method
signature.
|
protected void |
performBlockingOperation(java.nio.channels.AsynchronousFileChannel aChannel,
java.nio.ByteBuffer rData)
Must be implemented for the blocking execution of a step.
|
static FileWrite |
writeTo(java.util.function.Function<Continuation<?>,java.nio.channels.AsynchronousFileChannel> fGetFileChannel)
Suspends until all data from the input
ByteBuffer has been
written to a file.The buffer must be initialized for sending, i.e. if
necessary a call to Buffer.flip() must have been performed. |
static FileWrite |
writeTo(java.lang.String sFileName,
java.nio.file.OpenOption... rExtraOptions)
Invokes
writeTo(Function) with a function that opens a file
channel with the given file name and options. |
execute, getFileChannel, getFileChannelFactory, openFileChannel, runAsync
getChannelGroup
fail, runBlocking, terminateCoroutine, toString
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public FileWrite(java.util.function.Function<Continuation<?>,java.nio.channels.AsynchronousFileChannel> fGetFileChannel)
fGetFileChannel
- A function that provides the file channel from the
current continuationpublic static FileWrite writeTo(java.util.function.Function<Continuation<?>,java.nio.channels.AsynchronousFileChannel> fGetFileChannel)
ByteBuffer
has been
written to a file.The buffer must be initialized for sending, i.e. if
necessary a call to Buffer.flip()
must have been performed.
After the data has been fully written Buffer.clear()
will
be invoked on the buffer so that it can be used directly for subsequent
writing to it.
fGetFileChannel
- A function that provides the file channel from
the current continuationpublic static FileWrite writeTo(java.lang.String sFileName, java.nio.file.OpenOption... rExtraOptions)
writeTo(Function)
with a function that opens a file
channel with the given file name and options. The option StandardOpenOption.WRITE
will always be used and should therefore not
occur in the extra options.sFileName
- The name of the file to read fromrExtraOptions
- Additional options to use besides StandardOpenOption.WRITE
protected boolean performAsyncOperation(int nBytesWritten, java.nio.channels.AsynchronousFileChannel rChannel, java.nio.ByteBuffer rData, AsynchronousChannelStep.ChannelCallback<java.lang.Integer,java.nio.channels.AsynchronousFileChannel> rCallback)
protected void performBlockingOperation(java.nio.channels.AsynchronousFileChannel aChannel, java.nio.ByteBuffer rData) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
AsynchronousFileChannel
which must be accessed through the
blocking API (like Future.get()
).performBlockingOperation
in class AsynchronousFileStep
aChannel
- The channel to perform the operation onrData
- The byte buffer for the operation datajava.lang.InterruptedException
java.util.concurrent.ExecutionException