While reading the SequenceInputStream the second file(sample2.pdf) is not showing up in final pdf . Other formats like txt,xml,csv works fine . I don't want to use PDFReader or any other libraries for reading.
public class ReadStream{
private InputStream readInputStream()
{
//I have two input streams like below
List<InputStream> inputStream1= new ArrayList<>();
inputStream1.add(new FileInputStream("sample1.pdf"));
inputStream1.add(new FileInputStream("sample2.pdf"));
//And I use combine them like below
return new SequenceInputStream(Collections.enumeration(inputStream1));
}
}
Here is my test class
public class TestDemo{
@Test
public void testStream(){
try (InputStream stream = new ReadStream().readInputStream()) {
FileUtils.copyInputStreamToFile(stream,
new File("destFile.pdf"));
final byte[] decryptedBytes =Files.readAllBytes(new File("destFile.pdf");
Files.write(Paths.get("final.pdf"), decryptedBytes));
}
}
}
I could also see the size of SequenceInputStream as 2. Anyone who can shed some light would be appreciated. Also how to read the SequenceInputStream as List of InputStream separately?