Class FileIO$
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSource<ByteString,scala.concurrent.Future<IOResult>> Creates a Source from a files contents.Source<ByteString,scala.concurrent.Future<IOResult>> Creates a Source from a files contents.intSink<ByteString,scala.concurrent.Future<IOResult>> toPath(Path f, scala.collection.immutable.Set<OpenOption> options) Creates a Sink which writes incomingpekko.util.ByteStringelements to the given file path.Sink<ByteString,scala.concurrent.Future<IOResult>> toPath(Path f, scala.collection.immutable.Set<OpenOption> options, long startPosition) Creates a Sink which writes incomingpekko.util.ByteStringelements to the given file path.scala.collection.immutable.Set<OpenOption>
-
Field Details
-
MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Constructor Details
-
FileIO$
public FileIO$()
-
-
Method Details
-
fromPath
Creates a Source from a files contents. Emitted elements arechunkSizesizedpekko.util.ByteStringelements, except the final element, which will be up tochunkSizein size.You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcheror set it for a given Source by usingpekko.stream.ActorAttributes.It materializes a
FutureofIOResultcontaining 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.- Parameters:
f- the file path to read fromchunkSize- the size of each read operation, defaults to 8192
-
fromPath
public Source<ByteString,scala.concurrent.Future<IOResult>> fromPath(Path f, int chunkSize, long startPosition) Creates a Source from a files contents. Emitted elements arechunkSizesizedpekko.util.ByteStringelements, except the final element, which will be up tochunkSizein size.You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcheror set it for a given Source by usingpekko.stream.ActorAttributes.It materializes a
FutureofIOResultcontaining 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.- Parameters:
f- the file path to read fromchunkSize- the size of each read operation, defaults to 8192startPosition- the start position to read from
-
fromPath$default$2
public int fromPath$default$2() -
toPath
public Sink<ByteString,scala.concurrent.Future<IOResult>> toPath(Path f, scala.collection.immutable.Set<OpenOption> options) Creates a Sink which writes incomingpekko.util.ByteStringelements to the given file path. Overwrites existing files by truncating their contents as default.Materializes a
FutureofIOResultthat 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
pekko.stream.blocking-io-dispatcher, unless configured otherwise by usingpekko.stream.ActorAttributes.Accepts as arguments a set of
StandardOpenOption, which will determine the underlying behavior when writing the file. Ifjava.nio.file.StandardOpenOption.SYNCis 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.- Parameters:
f- the file path to write tooptions- File open options, seeStandardOpenOption, defaults to Set(WRITE, TRUNCATE_EXISTING, CREATE)
-
toPath
public Sink<ByteString,scala.concurrent.Future<IOResult>> toPath(Path f, scala.collection.immutable.Set<OpenOption> options, long startPosition) Creates a Sink which writes incomingpekko.util.ByteStringelements to the given file path. Overwrites existing files by truncating their contents as default.Materializes a
FutureofIOResultthat 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
pekko.stream.blocking-io-dispatcher, unless configured otherwise by usingpekko.stream.ActorAttributes.Accepts as arguments a set of
StandardOpenOption, which will determine the underlying behavior when writing the file. Ifjava.nio.file.StandardOpenOption.SYNCis 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.- Parameters:
f- the file path to write tooptions- File open options, seeStandardOpenOption, defaults to Set(WRITE, CREATE)startPosition- the start position to write to
-
toPath$default$2
-