Sha*_*anu 15 java ftp ftp-client
如何使用java程序从ftp服务器删除文件?我已成功使用以下代码在ftp上传文件:
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String s = "ftp://username:password@ftpclient:21/text.txt;type=i";
URL u = new URL(s);
URLConnection uc = u.openConnection();
BufferedOutputStream bos = new BufferedOutputStream(uc.getOutputStream());
bos.write(67);
bos.close();
System.out.println("Done");
}
Run Code Online (Sandbox Code Playgroud)
但是如何从这个ftp服务器中删除文件?任何帮助将不胜感激.........提前谢谢
ale*_*lum 22
您可以使用Apache FTPClient执行此操作以及FTP上的所有其他命令.使用这样的东西:
...
FTPClient client = new FTPClient();
client.connect(host, port);
client.login(loginname, password);
client.deleteFile(fileNameOnServer);
client.disconnect();
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21845 次 |
| 最近记录: |