在Android Studio中读取创建的data.txt内部存储数据具体应该怎么写代码,有人帮忙看一下吗,我一直都会报错

public class WriteActivity extends AppCompatActivity {

private Button save;
private EditText etwrite;
private TextView show;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_write);
    save = (Button) findViewById(R.id.save);
    etwrite = (EditText) findViewById(R.id.et_write);
    show = (TextView) findViewById(R.id.tv_show);

    save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //show.setText(write.getText().toString());
            String write = etwrite.getText().toString().trim();

            //public void save(String EditText){//inputText为传入的要保存的数据
            FileOutputStream out = null;
            BufferedWriter writer = null;
            try {
                out = openFileOutput("data", Context.MODE_APPEND);//"data"为文件名,第二个参数为文件操作模式:文件已经存在,就往文件里面追加类容,不从新创建文件。
                writer = new BufferedWriter(new OutputStreamWriter(out));
                writer.write(write);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (writer != null) {
                        writer.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            // }


            //读取数据

        }
    });
}

}

这个就是java文件IO啊,网上一大把,你这个问题应该是读取的格式不对,如果是读字符串,那你应该用字符流。

public void save()
{
try {
FileOutputStream outStream=this.openFileOutput(“a.txt”,Context.MODE_WORLD_READABLE);
outStream.write(text.getText().toString().getBytes());
outStream.close();
Toast.makeText(MyActivity.this,”Saved”,Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
return;
}
catch (IOException e){
return ;
}
}


```openFileOutput()方法的第一参数用于指定文件名称,不能包含路径分隔符“/” ,如果文件不存在,Android 会自动创建它。创建的文件保存在/data/data/<package name>/files目录,如: /data/data/cn.itcast.action/files/itcast.txt ,通过点击Eclipse菜单“Window”-“Show View”-“Other”,在对话窗口中展开android文件夹,选择下面的File Explorer视图,然后在File Explorer视图中展开/data/data/<package name>/files目录就可以看到该文件。
openFileOutput()方法的第二参数用于指定操作模式,有四种模式,分别为: Context.MODE_PRIVATE    =  0
Context.MODE_APPEND    =  32768
Context.MODE_WORLD_READABLE =  1
Context.MODE_WORLD_WRITEABLE =  2
Context.MODE_PRIVATE:为默认操作模式,代表该文件是私有数据,只能被应用本身访问,在该模式下,写入的内容会覆盖原文件的内容,如果想把新写入的内容追加到原文件中。可以使用Context.MODE_APPEND