Gson With Mixed Read
I'm trying to read json with gson, but I can't get a 'simple' gson example to work. From: https://sites.google.com/site/gson/streaming public List readJsonStrea
Solution 1:
Solution 2:
It is mentionned that the fromJson method accepts argument 0 as a String. Try to create a method that transforms the inputStream to a String.
staticpublic String generateString(InputStream stream) {
InputStreamReaderreader=newInputStreamReader(stream);
BufferedReaderbuffer=newBufferedReader(reader);
StringBuildersb=newStringBuilder();
try {
String cur;
while ((cur = buffer.readLine()) != null) {
sb.append(cur).append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
Post a Comment for "Gson With Mixed Read"