当我将此代码放在onCreate()中时,我的应用程序总是崩溃。我该如何删除错误?

时间:2015-06-06 16:53:37

标签: java android file-handling android-file

当我将此代码放在onCreate()方法中时,我的应用程序总是崩溃。请帮忙。

File dir = Environment.getExternalStorageDirectory();
    File file = new File(dir, "Gest_val.csv");
    String val1 = new String();
    try {
        Scanner inputStream = new Scanner(file);
        while (inputStream.hasNext()) {
            String data = inputStream.next();
            if (data.equals("+")) {
                tvOrientation.setText("found +");
                Modify_val.add(Integer.parseInt(val1));
                val1 = null;
            } else {
                tvOrientation.setText("NO +");
                val1 = data;
            }
        }
    } catch (IOException e) {
    }

0 个答案:

没有答案