Class StreamingUtils
java.lang.Object
dev.jcputney.elearning.parser.util.StreamingUtils
Utility class for working with streaming file operations. Provides enhanced streaming
capabilities including progress tracking and buffering.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault buffer size for buffered streams (64KB).static final longDefault progress update interval in bytes (1MB). -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamcreateBufferedStream(InputStream inputStream) Wraps an InputStream with buffering for improved performance.static InputStreamcreateBufferedStream(InputStream inputStream, int bufferSize) Wraps an InputStream with buffering for improved performance.static InputStreamcreateEnhancedStream(InputStream inputStream, long totalSize, StreamingProgressListener listener) Creates a combined buffered and progress-tracking stream.static InputStreamcreateProgressTrackingStream(InputStream inputStream, long totalSize, StreamingProgressListener listener) Creates a progress-tracking input stream that reports progress at regular intervals.static InputStreamcreateProgressTrackingStream(InputStream inputStream, long totalSize, StreamingProgressListener listener, long progressInterval) Creates a progress-tracking input stream with a custom progress interval.
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEDefault buffer size for buffered streams (64KB).- See Also:
-
DEFAULT_PROGRESS_INTERVAL
public static final long DEFAULT_PROGRESS_INTERVALDefault progress update interval in bytes (1MB).- See Also:
-
-
Method Details
-
createBufferedStream
Wraps an InputStream with buffering for improved performance.- Parameters:
inputStream- The input stream to wrap- Returns:
- A buffered input stream
-
createBufferedStream
Wraps an InputStream with buffering for improved performance.- Parameters:
inputStream- The input stream to wrapbufferSize- 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 wraptotalSize- 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 wraptotalSize- The total size of the stream in bytes (or -1 if unknown)listener- The progress listener to notifyprogressInterval- 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 wraptotalSize- 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
-