Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6165217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:07:40+00:00 2026-05-23T22:07:40+00:00

How can I delete a file from an ftp server using a java program?

  • 0

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 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");
}

But how do i delete files from this ftp server?
Any help will be greatly appreciated………
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:07:41+00:00Added an answer on May 23, 2026 at 10:07 pm

    You can use Apache FTPClient to do this and all other commands on FTP.
    Use it something like this:

    ...
    FTPClient client = new FTPClient();
    client.connect(host, port);
    client.login(loginname, password);
    client.deleteFile(fileNameOnServer);
    client.disconnect();
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a windows batch file that can delete files from subdirectories.
I have files that I want to delete. Connection can be from file sharing,
I use following code to delete old image from ftp... unlink(getcwd() . '/images/' .
Using VBA, how can I: test whether a file exists, and if so, delete
Following up from this question: How can I unlock a file that is locked
Before downloading a file from ftp server, I want to check it if exist
I've written a simple FTP based file synchronization program. The settings of which can
If you have superuser permissions you can delete apk file from data/app but app
I done delete image url from database with following code, but is not delete
If I delete a file in Subversion, how can I look at it's history

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.