1

Im currently playing with file downloads. But I'm currently facing a weird error :

05-23 17:39:45.917: E/(5036): java.io.FileNotFoundException: /mnt/sdcard/Pictures/"Samsung  ()+-* Samsung.jpg": open failed: EINVAL (Invalid argument)
05-23 17:39:45.917: E/(5036):   at libcore.io.IoBridge.open(IoBridge.java:406)
05-23 17:39:45.917: E/(5036):   at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
05-23 17:39:45.917: E/(5036):   at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
05-23 17:39:45.917: E/(5036):   at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
05-23 17:39:45.917: E/(5036):   at com.end.utils.InternalFileUtils.copyFile(InternalFileUtils.java:458)
05-23 17:39:45.917: E/(5036):   at com.end.activities.filopeartions.MultipleDownloadActivity$MultipleDownloadAsyncTask.downladFile(MultipleDownloadActivity.java:260)
05-23 17:39:45.917: E/(5036):   at com.end.activities.filopeartions.MultipleDownloadActivity$MultipleDownloadAsyncTask.doInBackground(MultipleDownloadActivity.java:209)
05-23 17:39:45.917: E/(5036):   at com.end.activities.filopeartions.MultipleDownloadActivity$MultipleDownloadAsyncTask.doInBackground(MultipleDownloadActivity.java:174)
05-23 17:39:45.917: E/(5036):   at android.os.AsyncTask$2.call(AsyncTask.java:264)
05-23 17:39:45.917: E/(5036):   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-23 17:39:45.917: E/(5036):   at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-23 17:39:45.917: E/(5036):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-23 17:39:45.917: E/(5036):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-23 17:39:45.917: E/(5036):   at java.lang.Thread.run(Thread.java:856)
05-23 17:39:45.917: E/(5036): Caused by: libcore.io.ErrnoException: open failed: EINVAL (Invalid argument)
05-23 17:39:45.917: E/(5036):   at libcore.io.Posix.open(Native Method)
05-23 17:39:45.917: E/(5036):   at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
05-23 17:39:45.917: E/(5036):   at libcore.io.IoBridge.open(IoBridge.java:390)
05-23 17:39:45.917: E/(5036):   ... 13 more

Here's my code :

458    FileChannel outChannel = new FileOutputStream(mediaFileName).getChannel();

And then I do other stuffs but I think the new FileOutputStream is where it crashes. One the character (surely the *) is in cause but I don't understand why and how I can make it work (since on android with adb shell, i can create a file with this name). Any idea ? thanks

Gomoku7
  • 1,362
  • 13
  • 31
  • 1
    See [this question](http://stackoverflow.com/questions/2679699/what-characters-allowed-in-file-names-on-android). Why not renaming? – Knickedi May 23 '12 at 16:40
  • Thanks. The filename is selected by the user of my app. – Gomoku7 May 23 '12 at 16:43
  • I dont get it. I can adb shell on my phone and create the file with this very same name... Why does it crash ? – Gomoku7 May 23 '12 at 16:48
  • 5
    I can create such a file via adb shell only if the filesystem supports that name (e.g. ext4 does) : `touch "\"Samsung ()+-\* Samsung.jpg\""` works on internal storage (ext4), but does not in `/mnt/sdcard/` since that is FAT which does not support those characters. – zapl May 23 '12 at 17:28

0 Answers0