Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7.5k views
in Java FTP by (140 points)
Hi

I am using J2SE 1.5 on OSX 10.4.9, edtFTPj 1.5.4.

I get an exception throws when I use .exists() on a directory name, is this only for files? If I don't check then I get an exception that the directory already exists. Is there a way around this?

20386 [AWT-EventQueue-0] ERROR Unable to determine if file 'Users/' exists.
20387 [AWT-EventQueue-0] ERROR ***Stack Trace***
20387 [AWT-EventQueue-0] ERROR com.enterprisedt.net.ftp.FTPClient.exists(FTPClient.java:1365)
20388 [AWT-EventQueue-0] ERROR robsit.util.FileUtils.createRecursiveDirectory(FileUtils.java:69)
20388 [AWT-EventQueue-0] ERROR robsit.net.EdtFtp.createRemoteDirectories(EdtFtp.java:39)
20388 [AWT-EventQueue-0] ERROR robsit.event.BackupActionListener.actionPerformed(BackupActionListener.java:138)
20388 [AWT-EventQueue-0] ERROR javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
20388 [AWT-EventQueue-0] ERROR javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
20388 [AWT-EventQueue-0] ERROR javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
20388 [AWT-EventQueue-0] ERROR javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
20388 [AWT-EventQueue-0] ERROR javax.swing.AbstractButton.doClick(AbstractButton.java:334)
20388 [AWT-EventQueue-0] ERROR apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:104)
20389 [AWT-EventQueue-0] ERROR java.awt.MenuItem.processActionEvent(MenuItem.java:597)
20389 [AWT-EventQueue-0] ERROR java.awt.MenuItem.processEvent(MenuItem.java:556)
20389 [AWT-EventQueue-0] ERROR java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:298)
20389 [AWT-EventQueue-0] ERROR java.awt.MenuComponent.dispatchEvent(MenuComponent.java:286)
20389 [AWT-EventQueue-0] ERROR java.awt.EventQueue.dispatchEvent(EventQueue.java:466)
20389 [AWT-EventQueue-0] ERROR java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
20389 [AWT-EventQueue-0] ERROR java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
20389 [AWT-EventQueue-0] ERROR java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
20390 [AWT-EventQueue-0] ERROR java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
20390 [AWT-EventQueue-0] ERROR java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
20390 [AWT-EventQueue-0] ERROR ***End of Stack Trace***

3 Answers

0 votes
by (162k points)
No, it is really only for files.

We'll make a note to extend it for directories - perhaps even a different method.

Best way to check is try to chdir into the directory. If you catch an FTPException assume it doesn't exist.

Alternatively use dirDetails() to see if the directory exists in the listing.
0 votes
by (820 points)
I second this. I just ran into this problem, where I'm trying to see if a directory exists before creating it. Alternatively, I could just try and create it every single time, I suppose, but it would be very nice to get this working.

I'm using the AsyncFileTransferClient though, not FTPClient. I also noticed that there is no way to get the current working dir through AsyncFileTransferClient, you need to execute("pwd") to find that. Fortunately don't specifically need it, except for maybe debugging, but it seems like a pretty glaring omission considering how packed full of awesome features this class is!
0 votes
by (162k points)
Thanks for the feedback, about time we did something about this. Have made a note to.

Categories

...