Re: How to delete an FTP file?

Discussion in 'Java' started by Scott Yanoff, Jul 22, 2003.

  1. Scott Yanoff

    Scott Yanoff Guest

    Biuri wrote:
    > I simply need the code to DELETE a file from an ftp connection (I'm
    > able to estabilish the connection, to read a file and to write a
    > file...but not to delete!!... :) )


    What FTP package are you using?
    I know that with com.enterprisedt.net.ftp you can do:
    FTPClient.delete(String filename);

    Good luck,

    --
    -Scott
    | http://www.yanoff.org | AOL IM: SAY KJY
     
    Scott Yanoff, Jul 22, 2003
    #1
    1. Advertising

  2. Scott Yanoff

    Biuri Guest

    > What FTP package are you using?
    > I know that with com.enterprisedt.net.ftp you can do:
    > FTPClient.delete(String filename);
    >
    > Good luck,


    I'm tring to implement something very simple for a project with my
    friends.I want to use only Java package, without other libraries...In
    Java this is a swear,but until now I got it... ;-)
    This is part of the code to make you understand how I'm proceeding:

    /* Creates a file in the path specified, in which
    * ther's written the String what. */
    public void writeFile(String username, String password,
    String filePath, String what) {
    try {
    URL url = new
    URL("ftp://"+username+":"+password+"@"+filePath);
    URLConnection urlc = url.openConnection();
    OutputStream os = urlc.getOutputStream();
    PrintWriter out = new PrintWriter(os);
    out.println(what);
    out.close();
    }
    catch (MalformedURLException e) { System.out.println("Not
    valid URL"); }
    catch (IOException e) { System.out.println("Errore di I/O"); }

    }
     
    Biuri, Jul 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Biuri
    Replies:
    1
    Views:
    445
    Tor Iver Wilhelmsen
    Jul 22, 2003
  2. someone

    FTP over SSL vs FTP over SSH

    someone, Apr 24, 2004, in forum: Java
    Replies:
    1
    Views:
    4,592
    iksrazal
    Apr 25, 2004
  3. Drew
    Replies:
    1
    Views:
    651
  4. Jeff Miller
    Replies:
    0
    Views:
    505
    Jeff Miller
    Mar 26, 2009
  5. D. Buck
    Replies:
    2
    Views:
    497
    D. Buck
    Jun 29, 2004
Loading...

Share This Page