Why you read a JSON file with a BufferedReader and not with JSON
Unable to read 900kb text file which has base64 conversion of the Image
-
14-10-2022 - |
Question
This is code I am using to read a file which includes Json format inside. File size is 901Kb. StringBuilder is unable to read the full file. It stops after 40 or 60 Lines.
@Override
protected void onPreExecute() {
super.onPreExecute();
String fname = "visitdetails_JSONN.txt";
String file_path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/VMS/";
try
{
text = new StringBuilder();
file = new File(file_path, fname);
if(file.exists())
{
//Log.e("Data", "File Found");
String line = null;
BufferedReader br = new BufferedReader(new FileReader(file));
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
//Log.e("Data", text.toString());
}
else
file.mkdirs();
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow