簡體   English   中英

Android在內部存儲上創建文件,我在做什么錯?

[英]Android create file on internal storage, what am i doing wrong?

        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)

您正在以錯誤的方式檢查它

new Scanner(new File(filename))

應該

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM