Log the JSON file that had problems when reading JSON
@@ -260,10 +260,11 @@ public class JSONUtil {
encoding = "UTF-8";
}
JSONArray jArray = new JSONArray();
- try{
- BufferedReader br = new BufferedReader(new InputStreamReader(is,encoding));
String line = null;
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is,
+ encoding));
while ((line = br.readLine()) != null) {
jArray.put(new JSONObject(line.trim()));
@@ -272,7 +273,10 @@ public class JSONUtil {
br.close();
return jArray;
} catch (Exception e) {
- throw new Exception("Error while reading json lines."+ e.getMessage());
+ String message = "Error while reading json lines:" + e.getMessage();
+ if (line != null)
+ message = message + "\n" + line;
+ throw new Exception(message);
}
}
