Package com.helger.commons.io.stream
Class StreamHelper.CopyCharStreamBuilder
- java.lang.Object
-
- com.helger.commons.io.stream.StreamHelper.CopyCharStreamBuilder
-
- Enclosing class:
- StreamHelper
public static class StreamHelper.CopyCharStreamBuilder extends Object implements IBuilder<ESuccess>
A simple builder to copy a Reader (from(Reader)) to an Writer (to(Writer)) with certain parameters. Callbuild()to execute the copying.- Since:
- 10.0.0
- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_CLOSE_FROMstatic booleanDEFAULT_CLOSE_TO
-
Constructor Summary
Constructors Constructor Description CopyCharStreamBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamHelper.CopyCharStreamBuilderbuffer(char[] a)ESuccessbuild()This method performs the main copyingStreamHelper.CopyCharStreamBuildercloseFrom(boolean b)StreamHelper.CopyCharStreamBuildercloseTo(boolean b)StreamHelper.CopyCharStreamBuildercopyCharCount(MutableLong a)StreamHelper.CopyCharStreamBuilderexceptionCallback(IExceptionCallback<IOException> a)StreamHelper.CopyCharStreamBuilderfrom(Reader a)StreamHelper.CopyCharStreamBuilderlimit(long n)StreamHelper.CopyCharStreamBuilderlimit(Long a)StreamHelper.CopyCharStreamBuilderprogressCallback(LongConsumer a)StreamHelper.CopyCharStreamBuilderto(Writer a)StreamHelper.CopyCharStreamBuilderunlimited()Ensure no limit in copying (which is also the default).
-
-
-
Field Detail
-
DEFAULT_CLOSE_FROM
public static final boolean DEFAULT_CLOSE_FROM
- See Also:
- Constant Field Values
-
DEFAULT_CLOSE_TO
public static final boolean DEFAULT_CLOSE_TO
- See Also:
- Constant Field Values
-
-
Method Detail
-
from
@Nonnull public StreamHelper.CopyCharStreamBuilder from(@Nullable Reader a)
- Parameters:
a- The Reader to read from. May benull.- Returns:
- this for chaining
-
closeFrom
@Nonnull public StreamHelper.CopyCharStreamBuilder closeFrom(boolean b)
- Parameters:
b-trueto close the Reader,falseto leave it open. Default isDEFAULT_CLOSE_FROM- Returns:
- this for chaining
-
to
@Nonnull public StreamHelper.CopyCharStreamBuilder to(@Nullable Writer a)
- Parameters:
a- The Writer to write to. May benull.- Returns:
- this for chaining
-
closeTo
@Nonnull public StreamHelper.CopyCharStreamBuilder closeTo(boolean b)
- Parameters:
b-trueto close the Writer,falseto leave it open.- Returns:
- this for chaining
-
buffer
@Nonnull public StreamHelper.CopyCharStreamBuilder buffer(@Nullable char[] a)
- Parameters:
a- The buffer to use. May benull.- Returns:
- this for chaining
-
limit
@Nonnull public StreamHelper.CopyCharStreamBuilder limit(long n)
- 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:
unlimited()
-
limit
@Nonnull public StreamHelper.CopyCharStreamBuilder limit(@Nullable Long a)
- 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()
-
unlimited
@Nonnull public StreamHelper.CopyCharStreamBuilder unlimited()
Ensure no limit in copying (which is also the default).- Returns:
- this for chaining
- See Also:
limit(long)
-
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
@Nonnull public StreamHelper.CopyCharStreamBuilder copyCharCount(@Nullable MutableLong a)
- 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
@Nonnull public StreamHelper.CopyCharStreamBuilder progressCallback(@Nullable LongConsumer a)
- 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
-
-