public final class ImmutableFileRepeatableInputStream extends InputStream
InputStream implementation that allows obtaining a repeatable stream from the contents of an immutable file that
already exists in the local file system.
The Mule Runtime is capable of generating larger than memory repeatable streams by buffering into a temporal file in the local file system. The problem with that approach is that when the contents of the original stream are already present in the file system, the temporary file is still created, consuming unnecessary disk space and IO time.
This class allows to generate an InputStream from a local file that the repeatable streaming engine will buffer from
instead of generating a new one.
Immutability is a MANDATORY PRECONDITION for using this class. The file WILL NOT be modified by this class or the
Mule streaming framework in any way. But at the same time, the file's immutability needs to be guaranteed, at least for the
duration of this stream's lifecycle. This means that while the file is in use by instances of this class, no other process or
thread can modify the file's content. Failing to meet this condition will result in dirty reads and content corruption. If this
condition cannot be assured, then use a regular FileInputStream instead.
Also keep in mind that the purpose of this class is to optimize repeatable streaming resources on certain cases. However, in
the context of a Mule application, the user can always decide to disable repeatable streaming, in which case, this stream will
not be treated in a repeatable manner. The user can also configure an in-memory streaming strategy, in which case the behavior
will be similar to using a FileInputStream.
Finally, notice that this stream is not auto closeable. close() method needs to be invoked explicitly.
| Constructor and Description |
|---|
ImmutableFileRepeatableInputStream(File file,
boolean autoDelete)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
File |
getFile() |
boolean |
isAutoDelete() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
public ImmutableFileRepeatableInputStream(File file, boolean autoDelete)
file - the File that contains the stream's contentsautoDelete - if true, the file will be deleted when close() is invoked.IllegalArgumentException - if the file cannot be foundpublic boolean isAutoDelete()
close() or not.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStreampublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic boolean markSupported()
markSupported in class InputStreamCopyright © 2025 MuleSoft, Inc.. All rights reserved.