Android在内部存储上创建文件,我做错了什么?

时间:2014-11-20 08:12:18

标签: java android

        String filename = job_no + ".csv";
        File newfile = new File(this.getFilesDir(), filename);
        try {
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(newfile), 64);
            byte[] bb = resultfile.getBytes();
            out.write(bb);
            out.flush();
            out.close();
        } catch (Exception e) {
            Log.d("", e.toString());
        }

我做错了什么?,它没有显示任何错误消息,也没有创建任何文件......

我用这个

检查它
  try { 
     String workbook_xml = new Scanner(new File(filename)).useDelimiter("\\Z").next();
     Log.d(workbook_xml, "");  
  } catch (FileNotFoundException e) { 
       Log.d("", "sdfsdfsdfsdf"); 
  }

它以sdfsdfsdfsdf error (FileNotFOund)

返回

1 个答案:

答案 0 :(得分:1)

你正在以错误的方式检查它

new Scanner(new File(filename))

应该是

new Scanner(new File(getFilesDir(), filename))