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

  • SEARCH
  • Home
  • 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 7813485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:53:01+00:00 2026-06-02T04:53:01+00:00

I am writing an application that involves multiple clients. One client uploads a file

  • 0

I am writing an application that involves multiple clients. One client uploads a file using FTP to a server, and then another client downloads the file and deletes it. I am using the FTP server kind of as a middleman to exchange information because I do not want the user to have to port forward. I have figured out how to upload a file, but I cannot figure out how to delete the file. The command for deleting a file using FTP is:

DELE <filename>

I have tried doing so, but with no success. Here is the code that I have tried:

public static void deleteFile(String name) throws IOException
{
    URL url = new URL("ftp://a1111111:password@mywebsite.com/public_html/misc/screenshots/picture.png;type=i");
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(url.openConnection().getOutputStream()));
    writer.write("DELE picture.png");
    writer.flush();
}

I have a feeling that the < filename > that I provided may be wrong because I did not include the directory names in the path. However, since I explicitly told the path that of the file in the URL, I am not quite sure what I am supposed to enter for the < filename >.

I have read other questions on this web site about problems very similar to this and all of the responses tell to use a library. The thing is, most of those libraries are written in pure Java so the developers of that library had to figure out a way to do what I am trying to do without a library. I want to do that as well. I do not like attaching extra files besides my own to the things that I make. So please, do not tell me to use a library – it’s not what I’m looking for.

If you need any clarification, please ask!

EDIT: If I use this code to receive a response:

    byte[] response = new byte[conn.getInputStream().available()];
    conn.getInputStream().read(response);
    System.out.println("Response: " + new String(response));

My command just gets echoed back:

Response: DELE test1.png
  • 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-06-02T04:53:02+00:00Added an answer on June 2, 2026 at 4:53 am

    I think you need to do the retrieve and delete in two separate operations; some random documentation I found for FtpURLConnection says, in part:

    This class Opens an FTP input (or output) stream given a URL. It works as a one shot FTP transfer :

    Login
    Get (or Put) the file
    Disconnect

    I did not see any methods in the documentation that would allow deleting a file.

    You may wish to use the URL mechanism to retrieve the file, but I would drop down to using raw sockets to delete the file. Create a new connection to the FTP command port, log in, and issue the DELE command manually. If this is the only step you’re taking, you might be able to get away with doing relatively poor error handling and maybe only two read() requests and simply show the output transcript to the user once you’re done.

    It’s a bit dirty, but I completely understand not wanting to carry around a megabyte of additional source to achieve the moral equivalent of echo -e "user foo\npass password\ndele /path/to/file\nlogout" | nc ftp.remote.example.com 21.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a TCP server application using Winsock. The client that connects to
I'm writing a web application that involves a continuous cycle of creating (and removing)
I am writing an application that helps book exchange between users. I am using
I'm writing an application that needs to uncompress data compressed by another application (which
I'm busy writing a application that refreshes a IFrame completely using javascript, now my
I am writing a flex application that involves modifying a textarea very frequently. I
I am writing (trying) a client server application with these 3 layers: Client and
I'm writing an application that involves having users enter time's in the following format:
I'm writing an application that listens for sound events (using messages passed in with
I have just been involved in writing an application that does not use Doctype's

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.