java,,package cn.o
分享于 点击 2891 次 点评:149
java,,package cn.o
package cn.outofmemory.snippets.core;import org.apache.commons.net.ftp.FTPClient;import java.io.IOException;public class DeleteFileFtp { public static void main(String[] args) { FTPClient client = new FTPClient(); try { client.connect("ftp.javacodegeeks.com"); client.login("username", "password"); // Set a string with the file you want to delete String filename = "/coomons/footer.jsp"; // Delete file boolean exist = client.deleteFile(filename); // Notify user for deletion if (exist) { System.out.println("File '"+ filename + "' deleted..."); } // Notify user that file doesn't exist else System.out.println("File '"+ filename + "' doesn't exist..."); client.logout(); } catch (IOException e) { e.printStackTrace(); } finally { try { client.disconnect(); } catch (IOException e) { e.printStackTrace(); } } }}
输出:
File '/coomons/footer.jsp' deleted...
用户点评