java - how to convert S3ObjectInputStream to PushbackInputStream -


i uploading excel(xls) file s3 , application should download file s3 , parse using apache poi reader. reader accepts inputstream type input proper parsing of excel expects pushbackinputstream. inputstream file downloaded s3 of type s3objectinputstream. how convert s3objectinputstream pushbackinputstream?

i tried directly passing s3objectinputstream (since inputstream) pushbackinputstream, resulted in following exception :

org.springframework.batch.item.itemstreamexception: failed initialize reader     @ org.springframework.batch.item.support.abstractitemcountingitemstreamitemreader.open(abstractitemcountingitemstreamitemreader.java:147)     @ org.springframework.batch.item.support.compositeitemstream.open(compositeitemstream.java:96) ..... ..... caused by: java.lang.illegalstateexception: inputstream must either support mark/reset, or wrapped pushbackinputstream @ org.springframework.batch.item.excel.poi.poiitemreader.openexcelfile(poiitemreader.java:82) ..... 

i tried casting s3objectinputstream pushbackinputstream, resulted in classcastexception.

java.lang.classcastexception: com.amazonaws.services.s3.model.s3objectinputstream cannot cast java.io.pushbackinputstream 

anyone knows solution this

this solved issue.

inputstream inputstream = s3object.getobjectcontent();  pushbackinputstream pushbackinputstream = new pushbackinputstream(inputstream); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -