Class StreamingUtils

java.lang.Object
dev.jcputney.elearning.parser.util.StreamingUtils

public final class StreamingUtils extends Object
Utility class for working with streaming file operations. Provides enhanced streaming capabilities including progress tracking and buffering.
  • Field Details

    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      Default buffer size for buffered streams (64KB).
      See Also:
    • DEFAULT_PROGRESS_INTERVAL

      public static final long DEFAULT_PROGRESS_INTERVAL
      Default progress update interval in bytes (1MB).
      See Also:
  • Method Details

    • createBufferedStream

      public static InputStream createBufferedStream(InputStream inputStream)
      Wraps an InputStream with buffering for improved performance.
      Parameters:
      inputStream - The input stream to wrap
      Returns:
      A buffered input stream
    • createBufferedStream

      public static InputStream createBufferedStream(InputStream inputStream, int bufferSize)
      Wraps an InputStream with buffering for improved performance.
      Parameters:
      inputStream - The input stream to wrap
      bufferSize - The buffer size to use
      Returns:
      A buffered input stream
    • createProgressTrackingStream

      public static InputStream createProgressTrackingStream(InputStream inputStream, long totalSize, StreamingProgressListener listener)
      Creates a progress-tracking input stream that reports progress at regular intervals.
      Parameters:
      inputStream - The input stream to wrap
      totalSize - The total size of the stream in bytes (or -1 if unknown)
      listener - The progress listener to notify
      Returns:
      A progress-tracking input stream
    • createProgressTrackingStream

      public static InputStream createProgressTrackingStream(InputStream inputStream, long totalSize, StreamingProgressListener listener, long progressInterval)
      Creates a progress-tracking input stream with a custom progress interval.
      Parameters:
      inputStream - The input stream to wrap
      totalSize - The total size of the stream in bytes (or -1 if unknown)
      listener - The progress listener to notify
      progressInterval - The interval in bytes at which to report progress
      Returns:
      A progress-tracking input stream
    • createEnhancedStream

      public static InputStream createEnhancedStream(InputStream inputStream, long totalSize, StreamingProgressListener listener)
      Creates a combined buffered and progress-tracking stream.
      Parameters:
      inputStream - The input stream to wrap
      totalSize - The total size of the stream in bytes (or -1 if unknown)
      listener - The progress listener to notify (can be null)
      Returns:
      A buffered, progress-tracking input stream