how to delete file from ftp server using java?

后端 未结 4 734
无人及你
无人及你 2021-02-19 04:07

How can I delete a file from an ftp server using a java program? I am successfully able to upload files on the ftp using the following code:

public static void m         


        
4条回答
  •  眼角桃花
    2021-02-19 04:50

    The FTP command to remove a file is RMD, I think you could use:

    String s = "ftp://username:password@ftpclient:21/text.txt;type=i";
    URL u = new URL(s);
    URLConnection uc = u.openConnection();
    PrintStream ps = new PrintStream((uc.getOutputStream()));
    ps.println("RMD " + .getPath());
    ps.close();
    

提交回复
热议问题