直接打开读取文件活动时强制关闭

时间:2012-10-19 10:21:29

标签: android android-file

我尝试直接访问此活动但强制关闭:

@Override   protected void onCreate(Bundle savedInstanceState) {        

super.onCreate(savedInstanceState);
setContentView(R.layout.log);
historyView = (TextView) findViewById (R.id.historyView);

String data = (String) getIntent().getExtras().get("data");
  try {             FileInputStream fin = openFileInput("data.txt");            InputStreamReader isr = new InputStreamReader(fin);
                    char[] inputBuffer = new char[data.length()];

        isr.read(inputBuffer);

        String readString = new String(inputBuffer);
                boolean isTheSame = data.equals(readString);

        historyView.setText(readString);        
  }

catch (FileNotFoundExceptione) {
        // TODO Auto-generated catch block 
        e.printStackTrace();        
}

catch (IOException e) {         
// TODO Auto-generated catch block
e.printStackTrace();        
  }

然而,当我从另一个写入并传递data的活动访问它时,它正在工作。为什么?究竟是什么问题?

0 个答案:

没有答案