Class AsyncFile

java.lang.Object
org.nustaq.kontraktor.asyncio.AsyncFile

public class AsyncFile extends Object
Created by moelrue on 5/4/15.
  • Constructor Details

    • AsyncFile

      public AsyncFile()
      create an unitialized AsyncFile. Use open to actually open a file
    • AsyncFile

      public AsyncFile(String file) throws IOException
      create an async file and open for read
      Parameters:
      file -
      Throws:
      IOException
    • AsyncFile

      public AsyncFile(String file, OpenOption... options) throws IOException
      create an async file and open with given options (e.g. StandardOptions.READ or 'StandardOpenOption.WRITE, StandardOpenOption.CREATE')
      Parameters:
      file -
      Throws:
      IOException
    • AsyncFile

      public AsyncFile(Path file, OpenOption... options) throws IOException
      Throws:
      IOException
  • Method Details

    • asInputStream

      public InputStream asInputStream()
    • asOutputStream

      public 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(Path file, OpenOption... options) throws IOException
      Throws:
      IOException
    • length

      public long length()
    • readFully

      public IPromise<AsyncFileIOEvent> readFully()
    • read

      public IPromise<AsyncFileIOEvent> read(long position, int chunkSize, ByteBuffer target)
    • write

      public IPromise<AsyncFileIOEvent> write(long filePosition, ByteBuffer source)
    • close

      public void close()