public class FileIO
extends java.lang.Object
Constructor and Description |
---|
FileIO() |
Modifier and Type | Method and Description |
---|---|
static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> |
fromFile(java.io.File f)
Deprecated.
Use `fromPath` instead. Since 2.4.5.
|
static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> |
fromFile(java.io.File f,
int chunkSize)
Deprecated.
Use `fromPath` instead. Since 2.4.5.
|
static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> |
fromPath(java.nio.file.Path f)
Creates a Source from a files contents.
|
static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> |
fromPath(java.nio.file.Path f,
int chunkSize)
Creates a synchronous Source from a files contents.
|
static 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.
|
static Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> |
toFile(java.io.File f)
Deprecated.
Use `toPath` instead. Since 2.4.5.
|
static <Opt extends java.nio.file.OpenOption> |
toFile(java.io.File f,
java.util.Set<Opt> options)
Deprecated.
Use `toPath` instead. Since 2.4.5.
|
static Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> |
toPath(java.nio.file.Path f)
Creates a Sink that writes incoming
ByteString elements to the given file path. |
static <Opt extends java.nio.file.OpenOption> |
toPath(java.nio.file.Path f,
java.util.Set<Opt> options)
Creates a Sink that writes incoming
ByteString elements to the given file path. |
static <Opt extends java.nio.file.OpenOption> |
toPath(java.nio.file.Path f,
java.util.Set<Opt> options,
long startPosition)
Creates a Sink that writes incoming
ByteString elements to the given file path. |
public static Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toFile(java.io.File f)
ByteString
elements to the given file.
Overwrites existing files by truncating their contents, if you want to append to an existing file use
#toFile(File, util.Set[OpenOption])
with java.nio.file.StandardOpenOption.APPEND
.
Materializes a 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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
f
- The file to write topublic static Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toPath(java.nio.file.Path f)
ByteString
elements to the given file path.
Overwrites existing files by truncating their contents, if you want to append to an existing file
#toPath(Path, util.Set[OpenOption])
with java.nio.file.StandardOpenOption.APPEND
.
Materializes a 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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
f
- The file path to write topublic static <Opt extends java.nio.file.OpenOption> Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toFile(java.io.File f, java.util.Set<Opt> options)
ByteString
elements to the given file.
Materializes a 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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
f
- The file to write tooptions
- File open options, see StandardOpenOption
public static <Opt extends java.nio.file.OpenOption> Sink<ByteString,java.util.concurrent.CompletionStage<IOResult>> toPath(java.nio.file.Path f, java.util.Set<Opt> options)
ByteString
elements to the given file path.
Materializes a 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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
f
- The file path to write tooptions
- File open options, see StandardOpenOption
public static <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)
ByteString
elements to the given file path.
Materializes a 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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
f
- The file path to write tooptions
- File open options, see StandardOpenOption
startPosition
- startPosition the start position to read from, defaults to 0public static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromFile(java.io.File f)
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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
It materializes a 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.
f
- the file to read frompublic static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromPath(java.nio.file.Path f)
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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
It materializes a 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.
f
- the file path to read frompublic static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromFile(java.io.File f, int chunkSize)
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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
It materializes a 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.
f
- the file to read fromchunkSize
- the size of each read operationpublic static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromPath(java.nio.file.Path f, int chunkSize)
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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
It materializes a 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.
f
- the file path to read fromchunkSize
- the size of each read operationpublic static Source<ByteString,java.util.concurrent.CompletionStage<IOResult>> fromPath(java.nio.file.Path f, int chunkSize, long startPosition)
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 akka.stream.blocking-io-dispatcher
or
set it for a given Source by using ActorAttributes
.
It materializes a 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.
f
- the file path to read fromchunkSize
- the size of each read operationstartPosition
- startPosition the start position to read from, defaults to 0