Results 1 to 1 of 1
- 04-28-2011, 03:57 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 5
- Rep Power
- 0
Check if file exists before download
hi everyone!
i'm using this code to download a file from ftp server:
Java Code:import org.apache.commons.net.ftp.FTPClient; import java.io.IOException; import java.io.FileOutputStream; public class FtpDownloadDemo { public static void main(String[] args) { FTPClient client = new FTPClient(); FileOutputStream fos = null; try { client.connect("ftp.domain.com"); client.login("admin", "secret"); // // The remote filename to be downloaded. // String filename = "sitemap.xml"; fos = new FileOutputStream(filename); // // Download file from FTP server // client.retrieveFile("/" + filename, fos); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } client.disconnect(); } catch (IOException e) { e.printStackTrace(); } } } }
My problem is that i want to check if the file exists in the ftp directory before i start downloading it. Thanks! :confused:
Similar Threads
-
How do I check if a database exists ...Any help?
By nmvictor in forum New To JavaReplies: 5Last Post: 05-09-2010, 04:21 PM -
File fp = new File(filePath);fp.exists() does not yeild proper result
By ganeshp in forum Advanced JavaReplies: 2Last Post: 04-07-2009, 06:25 AM -
How to check whether file is exists or not
By Java Tip in forum java.ioReplies: 0Last Post: 04-05-2008, 10:13 AM -
Check if a web page exists or not
By Java Tip in forum Java TipReplies: 0Last Post: 03-02-2008, 07:24 PM -
How an array can check that profile whether exists or not???
By hien_NU in forum New To JavaReplies: 1Last Post: 01-10-2008, 01:18 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks