Packages

object FileIO

Factories to create sinks and sources from files

Source
FileIO.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FileIO
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def fromPath(f: Path, chunkSize: Int, startPosition: Long): Source[ByteString, Future[IOResult]]

    Creates a Source from a files contents.

    Creates a Source from a files contents. Emitted elements are chunkSize sized akka.util.ByteString elements, except the final element, which will be up to chunkSize in size.

    You can configure the default dispatcher for this Source by changing the akka.stream.materializer.blocking-io-dispatcher or set it for a given Source by using akka.stream.ActorAttributes.

    It materializes a Future of IOResult containing the number of bytes read from the source file upon completion, and a possible exception if IO operation was not completed successfully.

    f

    the file path to read from

    chunkSize

    the size of each read operation, defaults to 8192

    startPosition

    the start position to read from

  2. def fromPath(f: Path, chunkSize: Int = 8192): Source[ByteString, Future[IOResult]]

    Creates a Source from a files contents.

    Creates a Source from a files contents. Emitted elements are chunkSize sized akka.util.ByteString elements, except the final element, which will be up to chunkSize in size.

    You can configure the default dispatcher for this Source by changing the akka.stream.materializer.blocking-io-dispatcher or set it for a given Source by using akka.stream.ActorAttributes.

    It materializes a Future of IOResult containing the number of bytes read from the source file upon completion, and a possible exception if IO operation was not completed successfully.

    f

    the file path to read from

    chunkSize

    the size of each read operation, defaults to 8192

  3. def toPath(f: Path, options: Set[OpenOption], startPosition: Long): Sink[ByteString, Future[IOResult]]

    Creates a Sink which writes incoming ByteString elements to the given file path.

    Creates a Sink which writes incoming ByteString elements to the given file path. Overwrites existing files by truncating their contents as default.

    Materializes a Future of IOResult that will be completed with the size of the file (in bytes) at the streams completion, and a possible exception if IO operation was not completed successfully.

    This source is backed by an Actor which will use the dedicated akka.stream.blocking-io-dispatcher, unless configured otherwise by using akka.stream.ActorAttributes.

    Accepts as arguments a set of java.nio.file.StandardOpenOption, which will determine the underlying behavior when writing the file. If java.nio.file.StandardOpenOption.SYNC is provided, every update to the file's content be written synchronously to the underlying storage device. Otherwise (the default), the write will be written to the storage device asynchronously by the OS, and may not be stored durably on the storage device at the time the stream completes.

    f

    the file path to write to

    options

    File open options, see java.nio.file.StandardOpenOption, defaults to Set(WRITE, CREATE)

    startPosition

    the start position to write to

  4. def toPath(f: Path, options: Set[OpenOption] = ...): Sink[ByteString, Future[IOResult]]

    Creates a Sink which writes incoming ByteString elements to the given file path.

    Creates a Sink which writes incoming ByteString elements to the given file path. Overwrites existing files by truncating their contents as default.

    Materializes a Future of IOResult that will be completed with the size of the file (in bytes) at the streams completion, and a possible exception if IO operation was not completed successfully.

    This source is backed by an Actor which will use the dedicated akka.stream.blocking-io-dispatcher, unless configured otherwise by using akka.stream.ActorAttributes.

    Accepts as arguments a set of java.nio.file.StandardOpenOption, which will determine the underlying behavior when writing the file. If java.nio.file.StandardOpenOption.SYNC is provided, every update to the file's content be written synchronously to the underlying storage device. Otherwise (the default), the write will be written to the storage device asynchronously by the OS, and may not be stored durably on the storage device at the time the stream completes.

    f

    the file path to write to

    options

    File open options, see java.nio.file.StandardOpenOption, defaults to Set(WRITE, TRUNCATE_EXISTING, CREATE)

Deprecated Value Members

  1. def fromFile(f: File, chunkSize: Int = 8192): Source[ByteString, Future[IOResult]]

    Creates a Source from a files contents.

    Creates a Source from a files contents. Emitted elements are chunkSize sized akka.util.ByteString elements, except the final element, which will be up to chunkSize in size.

    You can configure the default dispatcher for this Source by changing the akka.stream.materializer.blocking-io-dispatcher or set it for a given Source by using akka.stream.ActorAttributes.

    It materializes a Future of IOResult containing the number of bytes read from the source file upon completion, and a possible exception if IO operation was not completed successfully.

    f

    the file to read from

    chunkSize

    the size of each read operation, defaults to 8192

    Annotations
    @deprecated
    Deprecated

    (Since version 2.4.5) Use fromPath instead

  2. def toFile(f: File, options: Set[OpenOption] = ...): Sink[ByteString, Future[IOResult]]

    Creates a Sink which writes incoming ByteString elements to the given file.

    Creates a Sink which writes incoming ByteString elements to the given file. Overwrites existing files by truncating their contents as default.

    Materializes a Future of IOResult that will be completed with the size of the file (in bytes) at the streams completion, and a possible exception if IO operation was not completed successfully.

    This source is backed by an Actor which will use the dedicated akka.stream.blocking-io-dispatcher, unless configured otherwise by using akka.stream.ActorAttributes.

    f

    the file to write to

    options

    File open options, see java.nio.file.StandardOpenOption, defaults to Set(WRITE, TRUNCATE_EXISTING, CREATE)

    Annotations
    @deprecated
    Deprecated

    (Since version 2.4.5) Use toPath instead