how to delete file?


General J2EE: how to delete file?

  1. how to delete file? (4 messages)

    i use "" package to read and save files hosted in a ftp server,now,i can "get" and "put" files to ftp server,but i can't find the "delete" method in the "FtpClient" client,if after i read a file,i want to delete it,how can i do?
    thank you!

    Threaded Messages (4)

  2. Re: how to delete file?[ Go to top ]

    After you "get" the file from ftp server, you should know where the file is located on your file system. Hence, you can create a object and use the delete() method to delete the file. This method would return a boolean to indicate if the file deletion was successfully or not.
  3. Re: how to delete file?[ Go to top ]

    no,you misunderstand me,i want to delete the file from ftp server.
  4. Re: how to delete file?[ Go to top ]

    Since class has a constructor which takes URI as the parameter, you can create an instance with something like "" and then use the same old delete() method afterwards.
  5. FTPClient ftp = new FTPClient(); ftp.connect(ftpHost); ftp.login( ftpUser, ftpPWD ); //Returns true on successful login ftp.deleteFile(filePath); //Returns true on successful delete