[英]Read cached Json file as ByteArray with JsonReader
I cached a Json file as byte array and want to read it afterwards with the JsonReader . 我将Json文件缓存为字节数组,并希望随后使用JsonReader读取它。
However, the JsonReader takes a Reader as input parameter. 但是,JsonReader将Reader作为输入参数。
How can I convert me byte array to a Reader and is it worth doing so, or is there a straighter way of caching the InputStream of the Json file and read it afterwards by the JsonReader? 我该如何将字节数组转换为Reader,这样做是否值得,或者是否有更直接的方法来缓存Json文件的InputStream并随后由JsonReader读取它?
Looking forward to your responses! 期待您的回复!
You can chain ByteArrayInputStream
and InputStreamReader
to get the Reader
object, eg: 您可以链接ByteArrayInputStream
和InputStreamReader
以获取Reader
对象,例如:
byte[] array = new byte[50];//json file
Reader reader = new InputStreamReader(new ByteArrayInputStream(array));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.