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
Post a Comment