Class FileIO$
- java.lang.Object
-
- akka.stream.javadsl.FileIO$
-
public class FileIO$ extends java.lang.Object
Java API: Factories to create sinks and sources from files
-
-
Constructor Summary
Constructors Constructor Description FileIO$()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Source<ByteString,java.util.concurrent.CompletionStage<IOResult>>
fromFile(java.io.File f)
Deprecated.Use `fromPath` instead.Source<ByteString,java.util.concurrent.CompletionStage<IOResult>>
fromFile(java.io.File f, int chunkSize)
Deprecated.Use `fromPath` instead.Source<ByteString,java.util.concurrent.CompletionStage<IOResult>>
fromPath(java.nio.file.Path f)
Creates a Source from a files contents.Source<ByteString,java.util.concurrent.CompletionStage<IOResult>>
fromPath(java.nio.file.Path f, int chunkSize)
Creates a synchronous Source from a files contents.Source<ByteString,java.util.concurrent.CompletionStage<IOResult>>
fromPath(java.nio.file.Path f, int chunkSize, long startPosition)
Creates a synchronous Source from a files contents.Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>>
toFile(java.io.File f)
Deprecated.Use `toPath` instead.<Opt extends java.nio.file.OpenOption>
Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>>toFile(java.io.File f, java.util.Set<Opt> options)
Deprecated.Use `toPath` instead.Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>>
toPath(java.nio.file.Path f)
Creates a Sink that writes incomingByteString
elements to the given file path.<Opt extends java.nio.file.OpenOption>
Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>>toPath(java.nio.file.Path f, java.util.Set<Opt> options)
Creates a Sink that writes incomingByteString
elements to the given file path.<Opt extends java.nio.file.OpenOption>
Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>>toPath(java.nio.file.Path f, java.util.Set<Opt> options, long startPosition)
Creates a Sink that writes incomingByteString
elements to the given file path.
-
-
-
Field Detail
-
MODULE$
public static final FileIO$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
toFile
public Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toFile(java.io.File f)
Deprecated.Use `toPath` instead. Since 2.4.5.Creates a Sink that writes incomingByteString
elements to the given file. Overwrites existing files by truncating their contents, if you want to append to an existing file use {@link toFile(File, util.Set[OpenOption])} withjava.nio.file.StandardOpenOption.APPEND
.Materializes a
CompletionStage
ofIOResult
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.- Parameters:
f
- The file to write to
-
toPath
public Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toPath(java.nio.file.Path f)
Creates a Sink that writes incomingByteString
elements to the given file path. Overwrites existing files by truncating their contents, if you want to append to an existing file {@link toPath(Path, util.Set[OpenOption])} withjava.nio.file.StandardOpenOption.APPEND
.Materializes a
CompletionStage
ofIOResult
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.Accepts as arguments a set of
StandardOpenOption
, which will determine the underlying behavior when writing the file. Ifjava.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.- Parameters:
f
- The file path to write to
-
toFile
public <Opt extends java.nio.file.OpenOption> Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toFile(java.io.File f, java.util.Set<Opt> options)
Deprecated.Use `toPath` instead. Since 2.4.5.Creates a Sink that writes incomingByteString
elements to the given file.Materializes a
CompletionStage
ofIOResult
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.- Parameters:
f
- The file to write tooptions
- File open options, seeStandardOpenOption
-
toPath
public <Opt extends java.nio.file.OpenOption> Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toPath(java.nio.file.Path f, java.util.Set<Opt> options)
Creates a Sink that writes incomingByteString
elements to the given file path.Materializes a
CompletionStage
ofIOResult
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.Accepts as arguments a set of
StandardOpenOption
, which will determine the underlying behavior when writing the file. Ifjava.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.- Parameters:
f
- The file path to write tooptions
- File open options, seeStandardOpenOption
-
toPath
public <Opt extends java.nio.file.OpenOption> Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toPath(java.nio.file.Path f, java.util.Set<Opt> options, long startPosition)
Creates a Sink that writes incomingByteString
elements to the given file path.Materializes a
CompletionStage
ofIOResult
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.Accepts as arguments a set of
StandardOpenOption
, which will determine the underlying behavior when writing the file. Ifjava.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.- Parameters:
f
- The file path to write tooptions
- File open options, seeStandardOpenOption
startPosition
- startPosition the start position to read from, defaults to 0
-
fromFile
public Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromFile(java.io.File f)
Deprecated.Use `fromPath` instead. Since 2.4.5.Creates a Source from a files contents. Emitted elements areByteString
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.It materializes a
CompletionStage
ofIOResult
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.- Parameters:
f
- the file to read from
-
fromPath
public Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromPath(java.nio.file.Path f)
Creates a Source from a files contents. Emitted elements areByteString
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
akka.stream.materializer.blocking-io-dispatcher
or set it for a given Source by usingActorAttributes
.It materializes a
CompletionStage
ofIOResult
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.It is not possible to read FIFOs, also known as named pipes, with
fromPath
, trying to do so will potentially first block and then fail the stream.- Parameters:
f
- the file path to read from
-
fromFile
public Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromFile(java.io.File f, int chunkSize)
Deprecated.Use `fromPath` instead. Since 2.4.5.Creates a synchronous Source from a files contents. Emitted elements arechunkSize
sizedByteString
elements, except the last element, which will be up tochunkSize
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 usingActorAttributes
.It materializes a
CompletionStage
ofIOResult
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.- Parameters:
f
- the file to read fromchunkSize
- the size of each read operation
-
fromPath
public Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromPath(java.nio.file.Path f, int chunkSize)
Creates a synchronous Source from a files contents. Emitted elements arechunkSize
sizedByteString
elements, except the last element, which will be up tochunkSize
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 usingActorAttributes
.It materializes a
CompletionStage
ofIOResult
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.It is not possible to read FIFOs, also known as named pipes, with
fromPath
, trying to do so will potentially first block and then fail the stream.- Parameters:
f
- the file path to read fromchunkSize
- the size of each read operation
-
fromPath
public Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromPath(java.nio.file.Path f, int chunkSize, long startPosition)
Creates a synchronous Source from a files contents. Emitted elements arechunkSize
sizedByteString
elements, except the last element, which will be up tochunkSize
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 usingActorAttributes
.It materializes a
CompletionStage
ofIOResult
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.- Parameters:
f
- the file path to read fromchunkSize
- the size of each read operationstartPosition
- startPosition the start position to read from, defaults to 0
-
-