how to convert S3ObjectInputStream to PushbackInputStream <p>I am uploading an excel(xls) file to s3 and then another application should download that file from s3 and parse using Apache POI reader. The reader accepts <code>inputstream</code> type as the input but for proper parsing of the excel it expects <code>PushbackInputStream</code>. The inputstream i get from the file downloaded from s3 is of type <code>S3ObjectInputStream</code>. How do i convert <code>S3ObjectInputStream</code> to <code>PushbackInputStream</code>?</p> <p>I tried directly passing the <code>S3ObjectInputStream</code> (since this is an <code>inputStream</code>) to <code>PushbackInputStream</code>, but it resulted in the following exception :</p> <pre><code>org.springframework.batch.item.ItemStreamException: Failed to initialize the reader at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:147) at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:96) ..... ..... Caused by: java.lang.IllegalStateException: InputStream MUST either support mark/reset, or be wrapped as a PushbackInputStream at org.springframework.batch.item.excel.poi.PoiItemReader.openExcelFile(PoiItemReader.java:82) ..... </code></pre> <p>I tried casting S3ObjectInputStream to PushbackInputStream, but it resulted in classcastexception.</p> <pre><code>java.lang.ClassCastException: com.amazonaws.services.s3.model.S3ObjectInputStream cannot be cast to java.io.PushbackInputStream </code></pre> <p>Anyone knows the solution for this</p>