I am currently using an InpuStream to get a JSON response from my server.
I need to do 2 things with:
- Parsing it and displaying the values on the screen
- Save this feed on SDCard file
That gives me no issues at all when using these 2 methods one by one.
The parsing is made with GSON:
Gson gson = new Gson();
Reader reader = new InputStreamReader (myInputStream);
Result result = gson.FrmJson(reader, Result.class)
and the copy to SDCard is made with
FileOutputStream f (...) f.write (buffer)
Both of them have been tested.
TYhe problem is once the parsing is done, I want to write to SDCard and it breaks. I understand that my InputStream is closed, and that's the issue.
There is something close to my question here: How to Cache InputStream for Multiple Use
Is there a way to improve that solution and provide something that we can use?