How do you read the same inputstream twice? Is it possible to copy it somehow?
I need to get a image from web, save it locally and then return the saved image. I just thought it would be faster to use the same stream instead of starting a new stream to the downloaded content and then read it again.
You can use
org.apache.commons.io.IOUtils.copyto copy the contents of the InputStream to a byte array, and then repeatedly read from the byte array using a ByteArrayInputStream. E.g.: