public static class StreamHelper.CopyByteStreamBuilder extends Object implements IBuilder<ESuccess>
from(InputStream)) to an
OutputStream (to(OutputStream)) with certain parameters. Call
build() to execute the copying.| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_CLOSE_DESTINATION |
static boolean |
DEFAULT_CLOSE_SOURCE |
| Constructor and Description |
|---|
CopyByteStreamBuilder() |
| Modifier and Type | Method and Description |
|---|---|
StreamHelper.CopyByteStreamBuilder |
buffer(byte[] a) |
ESuccess |
build()
This method performs the main copying
|
StreamHelper.CopyByteStreamBuilder |
closeFrom(boolean b) |
StreamHelper.CopyByteStreamBuilder |
closeTo(boolean b) |
StreamHelper.CopyByteStreamBuilder |
copyByteCount(MutableLong a) |
StreamHelper.CopyByteStreamBuilder |
exceptionCallback(IExceptionCallback<IOException> a) |
StreamHelper.CopyByteStreamBuilder |
from(InputStream a) |
StreamHelper.CopyByteStreamBuilder |
limit(long n) |
StreamHelper.CopyByteStreamBuilder |
limit(Long a) |
StreamHelper.CopyByteStreamBuilder |
to(OutputStream a) |
StreamHelper.CopyByteStreamBuilder |
unlimited()
Ensure no limit in copying (which is also the default).
|
public static final boolean DEFAULT_CLOSE_SOURCE
public static final boolean DEFAULT_CLOSE_DESTINATION
@Nonnull public StreamHelper.CopyByteStreamBuilder from(@Nullable InputStream a)
a - The InputStream to read from. May be null.@Nonnull public StreamHelper.CopyByteStreamBuilder closeFrom(boolean b)
b - true to close the InputStream, false to
leave it open. Default is DEFAULT_CLOSE_SOURCE@Nonnull public StreamHelper.CopyByteStreamBuilder to(@Nullable OutputStream a)
a - The OutputStream to write to. May be null.@Nonnull public StreamHelper.CopyByteStreamBuilder closeTo(boolean b)
b - true to close the OutputStream, false to
leave it open.@Nonnull public StreamHelper.CopyByteStreamBuilder buffer(@Nullable byte[] a)
a - The buffer to use. May be null.@Nonnull public StreamHelper.CopyByteStreamBuilder limit(long n)
n - An optional maximum number of bytes to copied from the InputStream
to the OutputStream. May be < 0 to indicate no limit, meaning
all bytes are copied.unlimited()@Nonnull public StreamHelper.CopyByteStreamBuilder limit(@Nullable Long a)
a - An optional maximum number of bytes to copied from the InputStream
to the OutputStream. May be < 0 to indicate no limit, meaning
all bytes are copied. If null no limit is setunlimited()@Nonnull public StreamHelper.CopyByteStreamBuilder unlimited()
limit(long)@Nonnull public StreamHelper.CopyByteStreamBuilder exceptionCallback(@Nullable IExceptionCallback<IOException> a)
a - The Exception callback to be invoked, if an exception occurs. May
be null.@Nonnull public StreamHelper.CopyByteStreamBuilder copyByteCount(@Nullable MutableLong a)
a - An optional mutable long object that will receive the total number
of copied bytes. Note: and optional old value is overwritten.
Note: this is only called, if copying was successful, and not in
case of an exception.Copyright © 2014–2022 Philip Helger. All rights reserved.