Package com.helger.commons.io.stream
Class StreamHelper.CopyCharStreamBuilder
java.lang.Object
com.helger.commons.io.stream.StreamHelper.CopyCharStreamBuilder
- Enclosing class:
StreamHelper
A simple builder to copy a Reader (
from(Reader)) to an Writer
(to(Writer)) 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
-
Field Details
-
DEFAULT_CLOSE_FROM
public static final boolean DEFAULT_CLOSE_FROM- See Also:
-
DEFAULT_CLOSE_TO
public static final boolean DEFAULT_CLOSE_TO- See Also:
-
-
Constructor Details
-
CopyCharStreamBuilder
public CopyCharStreamBuilder()
-
-
Method Details
-
from
- Parameters:
a- The Reader to read from. May benull.- Returns:
- this for chaining
-
closeFrom
- Parameters:
b-trueto close the Reader,falseto leave it open. Default isDEFAULT_CLOSE_FROM- Returns:
- this for chaining
-
to
- Parameters:
a- The Writer to write to. May benull.- Returns:
- this for chaining
-
closeTo
- Parameters:
b-trueto close the Writer,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 chars to copied from the Reader to the Writer. May be < 0 to indicate no limit, meaning all chars are copied.- Returns:
- this for chaining
- See Also:
-
limit
- Parameters:
a- An optional maximum number of chars 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
@Nonnull public StreamHelper.CopyCharStreamBuilder exceptionCallback(@Nullable IExceptionCallback<IOException> a) - Parameters:
a- The Exception callback to be invoked, if an exception occurs. May benull.- Returns:
- this for chaining
-
copyCharCount
- Parameters:
a- An optional mutable long object that will receive the total number of copied chars. 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 chars written during the copy action. It is first invoked after some chars were written.- Returns:
- this for chaining
- Since:
- 11.0.3
-
build
This method performs the main copying
-