Could Not Write File on FTP server using FTPClient in Java
<p>I am reading files on a FTP server and writing that data into another file. But after properly reading the data I couldn't write the file on to the FTP server.</p>

<p>I can retrieve files using "retrieve file", but can not store file using the <code>storefile</code> function.</p>

<p>My code is:</p>

<pre><code>import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

public class FtpDemo {

public static void main(String args[]){

FTPClient client=new FTPClient();       
try {
                if(client.isConnected()){
                    client.disconnect();
                    Boolean isLog=client.logout();
                    System.out.println(isLog);
                }

                client.connect("server");
                Boolean isLogin=client.login("user","password");

                if(isLogin){
                    System.out.println("Login has been successfully");
                    FTPFile[] files=client.listFiles();
                    System.out.println("Login has been successfully"+files.length);
                    for(int i=0;i&lt;files.length;i++){
                        if(files[i].getName().equals("rajesh.txt")){
                            System.out.println("match has been successfully");
                            InputStream is=client.retrieveFileStream("/rajesh.txt");
                            BufferedReader br=new BufferedReader(new InputStreamReader(is));
                            String str;
                            String content="";
                            str=br.readLine();

                            while(str!=null){
                                content+=str;
                                str=br.readLine();
                            }

                            System.out.println(content);
                            Boolean isStore=client.storeFile("/rajesh.txt",is);
                            System.out.println(isStore);
                        }
                    }
                }
            }
            catch(Exception e){
                System.out.println(e.getMessage());
            }
        }
}
</code></pre>
