I am trying to use Commons VFS to download an FTP file from:

ftp://ftp.ncbi.nih.gov/pub/HomoloGene/current/homologene.data

Here is my code:

FileSystemManager fsm = VFS.getManager();
FileObject remoteFile =
fsm.resolveFile("ftp://ftp.ncbi.nih.gov/pub/HomoloGene/current/homologene.data";);
File tmp = File.createTempFile("download", ".txt");
tmp.deleteOnExit();
final FileObject tempFile = fsm.toFileObject(tmp);
FileUtil.copyContent(remoteFile, tempFile);

Now, sometimes this runs just fine and sometimes I get an exception:

Exception in thread "main" org.apache.commons.vfs.FileSystemException:
Could not read from
"ftp://ftp.ncbi.nih.gov/pub/HomoloGene/current/homologene.data";
because it is a not a file.
        at 
org.apache.commons.vfs.provider.AbstractFileObject.getInputStream(AbstractFileObject.java:1149)
        at 
org.apache.commons.vfs.provider.DefaultFileContent.getInputStream(DefaultFileContent.java:360)
        at org.apache.commons.vfs.FileUtil.writeContent(FileUtil.java:71)
        at org.apache.commons.vfs.FileUtil.copyContent(FileUtil.java:103)

Any ideas?  Is it just a problem with the remote FTP server being
flaky?  I haven't had this trouble before with this code.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to