FileIO

org.apache.pekko.stream.javadsl.FileIO
object FileIO

Java API: Factories to create sinks and sources from files

Attributes

Source
FileIO.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
FileIO.type

Members list

Value members

Concrete methods

def fromPath(f: Path): Source[ByteString, CompletionStage[IOResult]]

Creates a Source from a files contents. Emitted elements are ByteString elements, chunked by default by 8192 bytes, except the last element, which will be up to 8192 in size.

Creates a Source from a files contents. Emitted elements are ByteString elements, chunked by default by 8192 bytes, except the last element, which will be up to 8192 in size.

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

It materializes a java.util.concurrent.CompletionStage 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. Note that bytes having been read by the source does not give any guarantee that the bytes were seen by downstream stages.

Value parameters

f

the file path to read from

Attributes

Source
FileIO.scala
def fromPath(f: Path, chunkSize: Int): Source[ByteString, CompletionStage[IOResult]]

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

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

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

It materializes a java.util.concurrent.CompletionStage 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. Note that bytes having been read by the source does not give any guarantee that the bytes were seen by downstream stages.

Value parameters

chunkSize

the size of each read operation

f

the file path to read from

Attributes

Source
FileIO.scala
def fromPath(f: Path, chunkSize: Int, startPosition: Long): Source[ByteString, CompletionStage[IOResult]]

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

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

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

It materializes a java.util.concurrent.CompletionStage 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. Note that bytes having been read by the source does not give any guarantee that the bytes were seen by downstream stages.

Value parameters

chunkSize

the size of each read operation

f

the file path to read from

startPosition

startPosition the start position to read from, defaults to 0

Attributes

Source
FileIO.scala
def toPath(f: Path): Sink[ByteString, CompletionStage[IOResult]]

Creates a Sink that writes incoming ByteString elements to the given file path. Overwrites existing files by truncating their contents, if you want to append to an existing file util.Set[OpenOption]) with java.nio.file.StandardOpenOption.APPEND.

Creates a Sink that writes incoming ByteString elements to the given file path. Overwrites existing files by truncating their contents, if you want to append to an existing file util.Set[OpenOption]) with java.nio.file.StandardOpenOption.APPEND.

Materializes a java.util.concurrent.CompletionStage 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.

You can configure the default dispatcher for this Source by changing the pekko.stream.materializer.blocking-io-dispatcher or set it for a given Source by using pekko.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.

Value parameters

f

The file path to write to

Attributes

Source
FileIO.scala
def toPath[Opt <: OpenOption](f: Path, options: Set[Opt]): Sink[ByteString, CompletionStage[IOResult]]

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

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

Materializes a java.util.concurrent.CompletionStage 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.

You can configure the default dispatcher for this Source by changing the pekko.stream.materializer.blocking-io-dispatcher or set it for a given Source by using pekko.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.

Value parameters

f

The file path to write to

options

File open options, see java.nio.file.StandardOpenOption

Attributes

Source
FileIO.scala
def toPath[Opt <: OpenOption](f: Path, options: Set[Opt], startPosition: Long): Sink[ByteString, CompletionStage[IOResult]]

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

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

Materializes a java.util.concurrent.CompletionStage 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.

You can configure the default dispatcher for this Source by changing the pekko.stream.materializer.blocking-io-dispatcher or set it for a given Source by using pekko.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.

Value parameters

f

The file path to write to

options

File open options, see java.nio.file.StandardOpenOption

startPosition

startPosition the start position to read from, defaults to 0

Attributes

Source
FileIO.scala

Deprecated methods

def fromFile(f: File): Source[ByteString, CompletionStage[IOResult]]

Creates a Source from a files contents. Emitted elements are ByteString elements, chunked by default by 8192 bytes, except the last element, which will be up to 8192 in size.

Creates a Source from a files contents. Emitted elements are ByteString elements, chunked by default by 8192 bytes, except the last element, which will be up to 8192 in size.

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

It materializes a java.util.concurrent.CompletionStage 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. Note that bytes having been read by the source does not give any guarantee that the bytes were seen by downstream stages.

Value parameters

f

the file to read from

Attributes

Deprecated
true
Source
FileIO.scala
def fromFile(f: File, chunkSize: Int): Source[ByteString, CompletionStage[IOResult]]

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

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

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

It materializes a java.util.concurrent.CompletionStage 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. Note that bytes having been read by the source does not give any guarantee that the bytes were seen by downstream stages.

Value parameters

chunkSize

the size of each read operation

f

the file to read from

Attributes

Deprecated
true
Source
FileIO.scala
def toFile(f: File): Sink[ByteString, CompletionStage[IOResult]]

Creates a Sink that writes incoming ByteString elements to the given file. Overwrites existing files by truncating their contents, if you want to append to an existing file use util.Set[OpenOption]) with java.nio.file.StandardOpenOption.APPEND.

Creates a Sink that writes incoming ByteString elements to the given file. Overwrites existing files by truncating their contents, if you want to append to an existing file use util.Set[OpenOption]) with java.nio.file.StandardOpenOption.APPEND.

Materializes a java.util.concurrent.CompletionStage 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.

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

Value parameters

f

The file to write to

Attributes

Deprecated
true
Source
FileIO.scala
def toFile[Opt <: OpenOption](f: File, options: Set[Opt]): Sink[ByteString, CompletionStage[IOResult]]

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

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

Materializes a java.util.concurrent.CompletionStage 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.

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

Value parameters

f

The file to write to

options

File open options, see java.nio.file.StandardOpenOption

Attributes

Deprecated
true
Source
FileIO.scala