Here you can find the source of loadSentences(InputStream stream, List
public static void loadSentences(InputStream stream, List<JsonObject> jsonSentences) throws IOException
//package com.java2s; //License from project: Creative Commons License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import com.google.common.base.Preconditions; import com.google.gson.JsonObject; import com.google.gson.JsonParser; public class Main { public static JsonParser jsonParser = new JsonParser(); public static void loadSentences(InputStream stream, List<JsonObject> jsonSentences) throws IOException { Preconditions.checkNotNull(jsonSentences); BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8")); try {/*w ww . j a v a 2 s. c o m*/ String line = br.readLine(); while (line != null) { line = line.trim(); if (line.equals("") || line.charAt(0) == '#') { line = br.readLine(); continue; } JsonObject sentence = jsonParser.parse(line).getAsJsonObject(); jsonSentences.add(sentence); line = br.readLine(); } } finally { br.close(); } } }