hi
i want to upload an xml file from my computer to a server but i donot know is there is a website that do that i want to do it for test purposes but my server is not ready yet and i need to make sure that the program is running so i will post the code and if any one can help please replay
thank you in advance

  FTPClient client = new FTPClient();
    FileInputStream fis = null;

    try {

        client.connect("verzend.be");
        System.out.println("connection successed"+client.getReplyCode());
        client.login("test20", "xxxxx");
             System.out.println("login successed"+client.getReplyCode());
   client.enterLocalPassiveMode();
     client.setFileType(FTP.BINARY_FILE_TYPE);
          System.out.println("type successed");
      File file = new File("F:/list.txt");
        String filename = "myPDF.pdf";
        fis = new FileInputStream(file);
     System.out.println("file successed");
       boolean flag=client.storeFile("list.txt", fis);
        System.out.println("store successed"+flag);
        System.out.println(client.getReplyCode());
     if (!client.storeFile(file.getName(),fis)) {
            System.out.println("upload failed!");
          }       
         if (flag) {
                System.out.println("The first file is uploaded successfully.");
            }


        fis.close();
        client.logout();
    } catch (IOException e) {
        e.printStackTrace();
    } 

i get the value of the replay code 530 login failed

There is a MockFtpServer available and this works on your own computer.
For more details , check this link
http://mockftpserver.sourceforge.net/

You can get all the related artifacts using for this mock ftp server using this maven dipendancy .

<dependency>
    <groupId>org.mockftpserver</groupId>
    <artifactId>MockFtpServer</artifactId>
    <version>2.4</version>
    <scope>test</scope>
  </dependency>

More details are on this page
http://mockftpserver.sourceforge.net/stubftpserver-getting-started.html

Edited 3 Years Ago by subramanya.vl

This article has been dead for over six months. Start a new discussion instead.