【问题标题】:Unable to read 900kb text file which has base64 conversion of the Image无法读取具有图像 base64 转换的 900kb 文本文件
【发布时间】:2014-02-21 07:06:17
【问题描述】:

这是我用来读取包含 Json 格式的文件的代码。文件大小为 901Kb。 StringBuilder 无法读取完整文件。它在 40 或 60 行后停止。

@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();
    }
}

【问题讨论】:

    标签: android json file stringbuilder


    【解决方案1】:

    为什么使用 BufferedReader 而不是 JSON 读取 JSON 文件

    【讨论】:

    • 我正在使用 Gson 库将字符串值序列化为一个类。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    • 2014-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多