In my code I receive uploaded image file and want to save it in two different sizes.
I am saving it using the given code:
The files of size 0 bytes get saved with the given names.
when I save only one at a time then it gets saved properly.
Please help me to debug the problem.
Step 1 exhausts the input stream, so there's nothing in step 2 to read any more. You could read the entire contents of the input stream into memory using a ByteArrayOutputStream, and then work with the resulting byte[] as many times as you need to.