Download file Apache FTP Android
<p>I am download a file in android apache ftp client. Although I am not receiving error but warning in Logcat </p>

<p>Here is the code </p>

<pre><code>public void downloadFile(String filename) {
        BufferedOutputStream desFileStream = null;
        try {
            desFileStream = new BufferedOutputStream(new FileOutputStream(
                    Environment.getExternalStorageDirectory()),
                    8 * 1024);
            mFtp.retrieveFile(filename, desFileStream);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }
</code></pre>

<p>And my stacktrace is </p>

<pre><code>12-15 20:17:30.170: W/System.err(19182): java.io.FileNotFoundException: /mnt/sdcard: open failed: EISDIR (Is a directory)
12-15 20:17:30.180: W/System.err(19182):    at libcore.io.IoBridge.open(IoBridge.java:406)
12-15 20:17:30.180: W/System.err(19182):    at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:88)
12-15 20:17:30.180: W/System.err(19182):    at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:73)
12-15 20:17:30.215: W/System.err(19182):    at com.murtaza.msftp.myftpTask.downloadFile(myftpTask.java:82)
12-15 20:17:30.220: W/System.err(19182):    at com.murtaza.msftp.MainActivity$1.onItemClick(MainActivity.java:74)
12-15 20:17:30.281: W/System.err(19182):    at android.widget.AdapterView.performItemClick(AdapterView.java:292)
12-15 20:17:30.281: W/System.err(19182):    at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
12-15 20:17:30.307: W/System.err(19182):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
12-15 20:17:30.320: W/System.err(19182):    at android.widget.AbsListView$1.run(AbsListView.java:3168)
12-15 20:17:30.330: W/System.err(19182):    at android.os.Handler.handleCallback(Handler.java:605)
12-15 20:17:30.330: W/System.err(19182):    at android.os.Handler.dispatchMessage(Handler.java:92)
12-15 20:17:30.330: W/System.err(19182):    at android.os.Looper.loop(Looper.java:137)
12-15 20:17:30.330: W/System.err(19182):    at android.app.ActivityThread.main(ActivityThread.java:4340)
12-15 20:17:30.330: W/System.err(19182):    at java.lang.reflect.Method.invokeNative(Native Method)
12-15 20:17:30.340: W/System.err(19182):    at java.lang.reflect.Method.invoke(Method.java:511)
12-15 20:17:30.340: W/System.err(19182):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-15 20:17:30.340: W/System.err(19182):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-15 20:17:30.340: W/System.err(19182):    at dalvik.system.NativeStart.main(Native Method)
12-15 20:17:30.359: W/System.err(19182): Caused by: libcore.io.ErrnoException: open failed: EISDIR (Is a directory)
12-15 20:17:30.380: W/System.err(19182):    at libcore.io.Posix.open(Native Method)
12-15 20:17:30.380: W/System.err(19182):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
12-15 20:17:30.380: W/System.err(19182):    at libcore.io.IoBridge.open(IoBridge.java:390)
12-15 20:17:30.380: W/System.err(19182):    ... 17 more
</code></pre>

<p>After implementing </p>

<pre><code>Environment.getExternalStorageDirectory() + "/"+ filename
</code></pre>

<p>Giving Null Pointer Exception. StackTrace is</p>

<pre><code>12-15 20:47:26.350: E/AndroidRuntime(26296): FATAL EXCEPTION: main
12-15 20:47:26.350: E/AndroidRuntime(26296): java.lang.NullPointerException
12-15 20:47:26.350: E/AndroidRuntime(26296):    at org.apache.commons.net.SocketClient.getRemoteAddress(SocketClient.java:651)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:732)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at org.apache.commons.net.ftp.FTPClient._retrieveFile(FTPClient.java:1778)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at org.apache.commons.net.ftp.FTPClient.retrieveFile(FTPClient.java:1769)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at com.murtaza.msftp.myftpTask.downloadFile(myftpTask.java:85)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at com.murtaza.msftp.MainActivity$1.onItemClick(MainActivity.java:74)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.widget.AdapterView.performItemClick(AdapterView.java:292)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.widget.AbsListView$1.run(AbsListView.java:3168)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.os.Handler.handleCallback(Handler.java:605)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.os.Handler.dispatchMessage(Handler.java:92)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.os.Looper.loop(Looper.java:137)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at android.app.ActivityThread.main(ActivityThread.java:4340)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at java.lang.reflect.Method.invokeNative(Native Method)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at java.lang.reflect.Method.invoke(Method.java:511)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-15 20:47:26.350: E/AndroidRuntime(26296):    at dalvik.system.NativeStart.main(Native Method)
</code></pre>
