0

次のコードがあります。

    try{
             File sdCard = Environment.getExternalStorageDirectory();
             File directory = new File (sdCard.getAbsolutePath() + "/statReporter/");
             directory.mkdirs();

             //Path and name of XML file
             File file = new File(directory, appendTimeStamp("statReporter") + ".csv");
             FileOutputStream fOut = new FileOutputStream(file);
             OutputStreamWriter osw = new OutputStreamWriter(fOut);

             //Write to CSV File
             osw.write(message);
             osw.write(',');

             //Flush and close OutPutStreamWriter and close FileOutputStream
             osw.flush();
             osw.close();
             fOut.close();

             Log.d("File Logger:", "File write successfully!");

     }catch(IOException ioe){
             ioe.printStackTrace();
     }

次の例外が発生します。

java.io.FileNotFoundException: /mnt/sdcard/statReporter/Date:3/24/2013Time:11:932statReporter,.csv: open failed: ENOENT (No such file or directory)
4

2 に答える 2

0

エラーが見つかりました:

ファイル名を変更しました。":" と "/" と "," を削除しました

于 2013-04-24T17:18:29.563 に答える
0

ファイル名Date:3/24/2013Time:11:932statReporter,.csvには/セパレーターがあります..これはディレクトリと見なされます。

于 2013-04-24T17:18:59.890 に答える