In my program I am repeatedly reading a number of files like this:
String myLetter = "CoverSheet.rtf"; // actually has a full path
FileInputStream in = new FileInputStream(myLetter);
letterSection.importRtfDocument(in);
in.close();
Because there are many small files which are components to add to the document with importRtfDocument
, and thousands of letters to generate in a run, the processing is quite slow.
The importRtfDocument
method comes from a library I'm using, and needs to be given a FileInputStream
. This is where I'm stumped. I tried a few things like declaring a FileInputStream
for each file in the class and keeping them open - but reset()
isn't supported.
I have looked at other similar questions like this one:
How to Cache InputStream for Multiple Use
However, none seem to address my problem, to wit, how can I cache a FileInputStream
?