Package com.helger.base.io.stream
Class StreamHelper.CopyByteStreamBuilder
java.lang.Object
com.helger.base.io.stream.StreamHelper.CopyByteStreamBuilder
- Enclosing class:
StreamHelper
A simple builder to copy an InputStream (
from(InputStream)) to an OutputStream
(to(OutputStream)) with certain parameters. Call build() to execute the
copying.- Since:
- 10.0.0
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull StreamHelper.CopyByteStreamBuilderbuffer(byte @Nullable [] a) @NonNull ESuccessbuild()This method performs the main copying@NonNull StreamHelper.CopyByteStreamBuildercloseFrom(boolean b) @NonNull StreamHelper.CopyByteStreamBuildercloseTo(boolean b) @NonNull StreamHelper.CopyByteStreamBuildercopyByteCount(@Nullable MutableLong a) @NonNull StreamHelper.CopyByteStreamBuilderexceptionCallback(@Nullable IExceptionCallback<IOException> a) @NonNull StreamHelper.CopyByteStreamBuilderfrom(@Nullable InputStream a) @NonNull StreamHelper.CopyByteStreamBuilderlimit(long n) @NonNull StreamHelper.CopyByteStreamBuilder@NonNull StreamHelper.CopyByteStreamBuilderprogressCallback(@Nullable LongConsumer a) @NonNull StreamHelper.CopyByteStreamBuilderto(@Nullable OutputStream a) @NonNull StreamHelper.CopyByteStreamBuilderEnsure no limit in copying (which is also the default).
-
Field Details
-
DEFAULT_CLOSE_SOURCE
public static final boolean DEFAULT_CLOSE_SOURCE- See Also:
-
DEFAULT_CLOSE_DESTINATION
public static final boolean DEFAULT_CLOSE_DESTINATION- See Also:
-
-
Constructor Details
-
CopyByteStreamBuilder
public CopyByteStreamBuilder()
-
-
Method Details
-
from
- Parameters:
a- The InputStream to read from. May benull.- Returns:
- this for chaining
-
closeFrom
- Parameters:
b-trueto close the InputStream,falseto leave it open. Default isDEFAULT_CLOSE_SOURCE- Returns:
- this for chaining
-
to
- Parameters:
a- The OutputStream to write to. May benull.- Returns:
- this for chaining
-
closeTo
- Parameters:
b-trueto close the OutputStream,falseto leave it open.- Returns:
- this for chaining
-
buffer
- Parameters:
a- The buffer to use. May benull.- Returns:
- this for chaining
-
limit
- Parameters:
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.- Returns:
- this for chaining
- See Also:
-
limit
- Parameters:
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. Ifnullno limit is set- Returns:
- this for chaining
- Since:
- 10.1.0
- See Also:
-
unlimited
Ensure no limit in copying (which is also the default).- Returns:
- this for chaining
- See Also:
-
exceptionCallback
public @NonNull StreamHelper.CopyByteStreamBuilder exceptionCallback(@Nullable IExceptionCallback<IOException> a) - Parameters:
a- The Exception callback to be invoked, if an exception occurs. May benull.- Returns:
- this for chaining
-
copyByteCount
- Parameters:
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.- Returns:
- this for chaining
-
progressCallback
- Parameters:
a- An optional progress callback that takes the number of total bytes written during the copy action. It is first invoked after some byte were written.- Returns:
- this for chaining
- Since:
- 11.0.3
-
build
This method performs the main copying
-