Android - java.io.FileNotFoundException

前端 未结 4 1875

when i was inserting the bitmap image to files directory, it showing file not found exception and it is showing Is a Directory.

Here is my code:

             


        
4条回答
  •  伪装坚强ぢ
    2020-12-19 02:57

    File sdcard = Environment.getExternalStorageDirectory();
    File dir = new File(sdcard.getAbsolutePath() + "/text/");
    dir.mkdir();
    File file = new File(dir, "sample.txt");
    FileOutputStream os = null;
    try {
        os = new FileOutputStream(file);
        os.write(enterText.getText().toString().getBytes());
        os.close();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    

提交回复
热议问题