Class StreamHelper.CopyCharStreamBuilder

java.lang.Object
com.helger.base.io.stream.StreamHelper.CopyCharStreamBuilder
All Implemented Interfaces:
IBuilder<ESuccess>
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. Call build() to execute the copying.
Since:
10.0.0
Author:
Philip Helger
  • Field Details

  • Constructor Details

    • CopyCharStreamBuilder

      public CopyCharStreamBuilder()
  • Method Details

    • from

      public @NonNull StreamHelper.CopyCharStreamBuilder from(@Nullable Reader a)
      Parameters:
      a - The Reader to read from. May be null.
      Returns:
      this for chaining
    • closeFrom

      public @NonNull StreamHelper.CopyCharStreamBuilder closeFrom(boolean b)
      Parameters:
      b - true to close the Reader, false to leave it open. Default is DEFAULT_CLOSE_FROM
      Returns:
      this for chaining
    • to

      public @NonNull StreamHelper.CopyCharStreamBuilder to(@Nullable Writer a)
      Parameters:
      a - The Writer to write to. May be null.
      Returns:
      this for chaining
    • closeTo

      public @NonNull StreamHelper.CopyCharStreamBuilder closeTo(boolean b)
      Parameters:
      b - true to close the Writer, false to leave it open.
      Returns:
      this for chaining
    • buffer

      public @NonNull StreamHelper.CopyCharStreamBuilder buffer(char @Nullable [] a)
      Parameters:
      a - The buffer to use. May be null.
      Returns:
      this for chaining
    • limit

      public @NonNull 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:
    • limit

      public @NonNull 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. If null no limit is set
      Returns:
      this for chaining
      Since:
      10.1.0
      See Also:
    • unlimited

      public @NonNull StreamHelper.CopyCharStreamBuilder unlimited()
      Ensure no limit in copying (which is also the default).
      Returns:
      this for chaining
      See Also:
    • exceptionCallback

      public @NonNull StreamHelper.CopyCharStreamBuilder exceptionCallback(@Nullable IExceptionCallback<IOException> a)
      Parameters:
      a - The Exception callback to be invoked, if an exception occurs. May be null.
      Returns:
      this for chaining
    • copyCharCount

      public @NonNull 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

      public @NonNull 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
    • build

      public @NonNull ESuccess build()
      This method performs the main copying
      Specified by:
      build in interface IBuilder<ESuccess>
      Returns:
      The built object. May not be null.