Package org.nustaq.kontraktor.asyncio
Class AsyncFile
java.lang.Object
org.nustaq.kontraktor.asyncio.AsyncFile
public class AsyncFile
extends java.lang.Object
Created by moelrue on 5/4/15.
-
Constructor Summary
Constructors Constructor Description AsyncFile()
create an unitialized AsyncFile.AsyncFile(java.lang.String file)
create an async file and open for readAsyncFile(java.lang.String file, java.nio.file.OpenOption... options)
create an async file and open with given options (e.g.AsyncFile(java.nio.file.Path file, java.nio.file.OpenOption... options)
-
Method Summary
Modifier and Type Method Description java.io.InputStream
asInputStream()
java.io.OutputStream
asOutputStream()
return a pseudo-blocking output stream.void
close()
long
length()
void
open(java.nio.file.Path file, java.nio.file.OpenOption... options)
IPromise<AsyncFileIOEvent>
read(long position, int chunkSize, java.nio.ByteBuffer target)
IPromise<AsyncFileIOEvent>
readFully()
IPromise<AsyncFileIOEvent>
write(long filePosition, java.nio.ByteBuffer source)
-
Constructor Details
-
AsyncFile
public AsyncFile()create an unitialized AsyncFile. Use open to actually open a file -
AsyncFile
public AsyncFile(java.lang.String file) throws java.io.IOExceptioncreate an async file and open for read- Parameters:
file
-- Throws:
java.io.IOException
-
AsyncFile
public AsyncFile(java.lang.String file, java.nio.file.OpenOption... options) throws java.io.IOExceptioncreate an async file and open with given options (e.g. StandardOptions.READ or 'StandardOpenOption.WRITE, StandardOpenOption.CREATE')- Parameters:
file
-- Throws:
java.io.IOException
-
AsyncFile
public AsyncFile(java.nio.file.Path file, java.nio.file.OpenOption... options) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
asInputStream
public java.io.InputStream asInputStream() -
asOutputStream
public java.io.OutputStream asOutputStream()return a pseudo-blocking output stream. Note: due to limitations of the current await implementation (stack based), when writing many files concurrently from a single actor thread don't mix high latency file locations (e.g. remote file systems vs. local) with low latency ones. If this is required, fall back to the more basic read/write methods returning futures.- Returns:
-
open
public void open(java.nio.file.Path file, java.nio.file.OpenOption... options) throws java.io.IOException- Throws:
java.io.IOException
-
length
public long length() -
readFully
-
read
-
write
-
close
public void close()
-