imName
- это непустая строка.
File f = new File(getFilesDir().toString(),"myP");
if(!f.isDirectory())
{
f.mkdirs();
}
File fff=new File(f,imName);
//fff.createNewFile();
System.out.println("fff.getPath "+fff.getAbsolutePath());
FileOutputStream fo = new FileOutputStream(fff);
FileOutputStream fo = new FileOutputStream(fff);
выдает ошибку, как показано ниже.
2020-05-01 16:12:18.522 13253-13253/com.example.testingproject W/System.err: java.io.FileNotFoundException: /data/user/0/com.example.testingproject/files/myP/jpg_20200501_1612009_.jpg (Not a directory)
2020-05-01 16:12:18.522 13253-13253/com.example.testingproject W/System.err: at java.io.FileOutputStream.open(Native Method)
2020-05-01 16:12:18.523 13253-13253/com.example.testingproject W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
2020-05-01 16:12:18.523 13253-13253/com.example.testingproject W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
2020-05-01 16:12:18.523 13253-13253/com.example.testingproject W/System.err: at com.example.testingproject.MainActivity.onActivityResult(MainActivity.java:79)
2020-05-01 16:12:18.525 13253-13253/com.example.testingproject W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:6915)
2020-05-01 16:12:18.525 13253-13253/com.example.testingproject W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)
2020-05-01 16:12:18.526 13253-13253/com.example.testingproject W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)
2020-05-01 16:12:18.526 13253-13253/com.example.testingproject W/System.err: at android.app.ActivityThread.-wrap20(ActivityThread.java)
2020-05-01 16:12:18.526 13253-13253/com.example.testingproject W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)
2020-05-01 16:12:18.528 13253-13253/com.example.testingproject W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
2020-05-01 16:12:18.528 13253-13253/com.example.testingproject W/System.err: at android.os.Looper.loop(Looper.java:154)
2020-05-01 16:12:18.528 13253-13253/com.example.testingproject W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6077)
2020-05-01 16:12:18.529 13253-13253/com.example.testingproject W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-05-01 16:12:18.529 13253-13253/com.example.testingproject W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
2020-05-01 16:12:18.531 13253-13253/com.example.testingproject W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Распечатка системы: fff.getPath /data/user/0/com.example.testingproject/files/myP/jpg_20200501_1612009_.jpg
Файл существует, как и папка. Иногда ошибка говорит, что местоположение не является каталогом. В чем может быть проблема?