بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
خطا در FileOutPutStream در کپی کردن فایل هایی غیر از Directory (حل شد)
سلام
من از این کد برای کپی استفاده می کنم توی کپی Directory خطا ندارد ولی برای غیر از Directory خطا داره نمیدونم چرا..........
public void copyDirectory(File sourceLocation, File targetLocation)
throws IOException {
if (sourceLocation.isDirectory()) {
if (!targetLocation.exists() && !targetLocation.mkdirs()) {
throw new IOException("Cannot create dir " + targetLocation.getAbsolutePath());
}
String[] children = sourceLocation.list();
for (int i = 0; i < children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
}
} else {
// make sure the directory we plan to store the recording in exists
File directory = targetLocation.getParentFile();
if (directory != null && !directory.exists() && !directory.mkdirs()) {
throw new IOException("Cannot create dir " + directory.getAbsolutePath());
}
FileInputStream fileInputStream = new FileInputStream(sourceLocation);
FileOutputStream fileOutputStream = new FileOutputStream(targetLocation);
// Copy the bits from instream to outstream
byte[] buffer = new byte[8*1024];
int len;
while ((len = fileInputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, len);
}
fileInputStream.close();
fileOutputStream.close();
}
}
به manifest برای این permission برای write external storage رو اضافه کردم.
محل کپی من از جنس File هستش ولی این اروری رو که گفتم رو میده....
(e: java.io.FileNotFoundException: /storage/emulated/0/PICTURES: open failed: EISDIR (Is a directory
این محل کپی من هستش که ازش این خطا رو میگره نمی فهمم چرا................ /storage/emulated/0/PICTURES
برای این سوال پاسخی وجود ندارد.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .