android - How to save and retrieve InputStream in text file with less overhead -


i retrieving/downloading json feed inputstreamreader , need pass inputstreamreader jsonreader parsing it.

jsonreader reader = new jsonreader(isr); // isr inputstreamreader instance 

everything okay. want cache inputstreamreader or data in other format internal storage later use. caching, using text file save. (afaik, android default cache saves data in external storage , devices have no external storage).

for saving file, using .txt file. able save/cache string formatted data file , read string. code have written far write & read file:

public static void writeobject(context context, string key, object object)         throws ioexception {     fileoutputstream fos = context             .openfileoutput(key, context.mode_private);     objectoutputstream oos = new objectoutputstream(fos);     oos.writeobject(object);     oos.close();     fos.close(); }  public static object readobject(context context, string key)         throws ioexception, classnotfoundexception {     fileinputstream fis = context.openfileinput(key);     objectinputstream ois = new objectinputstream(fis);     object object = ois.readobject();     return object; } 

but approach taking conversion:

inputstreamreader -> inputstream -> string //to save string -> inputstream -> inputstreamreader // retrieve   

how can save/cache data less overhead? perhaps inputstreamreader needs converted outputstreamreader or writable. can't figure out associative code this. should code? can cache data android's proposed way later use intead of saving .txt file?

you can't short process string best format save information in file afaik. inputstreamreader & inputstream not suitable object written. there may other better explanatory answer :)


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -