Save file in Android: java.io.FileNotFoundException. open failed: ENOENT (No such file or directory)
<p>I've a next problem... I searched answer on the source, but didn't find a good answer... </p>

<pre><code>java.io.FileNotFoundException: /mounted/EmailClient/side-corner.png: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:453)
at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.
at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:73) etc
</code></pre>

<p>Code:</p>

<pre><code>private static String saveFile(String filename, InputStream input) {
    String path = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(path)) {
        try {
            byte[] attachment = new byte[input.available()];
            input.read(attachment);
            File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/EmailClient/", filename);
            if (!file.mkdirs())
                Log.d("EmailClient", "saveFile: Dir not created");
            FileOutputStream out = new FileOutputStream(file); //PROBLEM!
            out.write(attachment);
            input.close();
            out.close();
            return path;
        } catch (IOException e) {
            Log.e("EmailClient", "saveFile: File not saved", e);;
        }
    }
    return path;
}
</code></pre>