I searched all through the related threads and i was not successful , any related answers are welcomed .
I have a JSON data as a .json file in SDCard inside the .NewFolder folder ,
i want to read the data in the file and parse , find the timestamp and want to rewrite it if the timestamp is different .
The below is the code i use , and i get the data in aBuffer and the value in jdata_fromfile but i get nullPointerException while parsing .
myFile = new File(Environment.getExternalStorageDirectory() + "/.NewFolder/" +str.get(i));
if(myFile.exists())
{
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn));
String aDataRow = "";
String aBuffer = "";
while ((aDataRow = myReader.readLine()) != null)
{
aBuffer += aDataRow;
}
myReader.close();
jdata_fromfile = new JSONObject(aBuffer);
String timestamp_fromfile = jdata_fromfile.getString(str_timestamp.get(i));
timestamp_val_fromfile.add(timestamp_fromfile);
}
else
{
myFile.createNewFile();
writedate_tofile(value_json.toString());
timestamp_val_fromfile.add("xxx");
}
And also that , when i open the file in the Notepad , it is all in a single line showing only a part of the data and when i copy to http://jsonformatter.curiousconcept.com
i get the whole data and a valid json . i could see the rest of the data in the notepad when i do - ctrl+end and press enter .
why is this and where do i go wrong ?
This is my Error - log
02-13 18:44:52.109: E/aBuffer value(7134): is {"Status":{"Itemlist":[{"x - Drinks":{"Details":[{"type":"","image":"","price":"","name":"Minerals"},{"type":"","image":"","price":"","name":"Milk Shakes"},{"type":"","image":"","price":"","name":"Milk"},{"type":"","image":"","price":"","name":"Mineral Water"},{"type":"","image":"","price":"","name":"Hot Beverages"},{"type":"","image":"","price":"","name":"Chocolate Muffin and Ice Cream"}, ........................................................................{"type":"","image":"","price":"","name":"Blu
02-13 18:44:52.189: E/jdata_fromfile value(7134): is {"x Time_stamp":"2013-02-12 12:30:00","Status":{"Itemlist":[{"x - Sides":{"Details":[{"type":"","image":"","name":"Onion Rings (6)","price":""},{"type":"","image":"","name":"Sausage Portion (Minimum 2 per portion)","price":""},.................................................................................................................... ,"x - Burgers":{"Details":[{"type":"","image":"","name":"x 5oz Burger","price":""},{"type":"","image":"","name":"x 5oz Cheese Burger","price":""},{"type":"","image":"","name":"x 5oz with Bacon and Cheese","price":""},{"type":"","imag
02-13 18:44:52.189: E/Reading from internal file - Exception e(7134): java.lang.NullPointerException
Thanks in advance .