commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject [vfs] Inconsistent Behavior...
Date Tue, 29 Jan 2008 02:29:37 GMT
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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message