commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derrick Rice" <derrick.r...@gmail.com>
Subject [vfs] FTP file not existing incorrectly
Date Wed, 05 Mar 2008 17:37:06 GMT
Hello,  I'm having trouble with the VFS component in an attempt to use
it to read FTP files.  Here's the basic code I am using, and it is
failing by claiming that the file does not exist, but you can plug it
into your web browser and see very clearly that it does.

The source of the trouble seems to be that the "data" folder is not
readable (cannot see listing), and that you must go directly to the
target file, rather than navigate through the file structure.  I've
tried on other FTP files that I can navigate to and they work
successfully.  How can I resolve this?  I had thought I could use some
config option to have the FtpFileSystem go directly to the file, but I
see no such option:

http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.html

Code:

String path = "ftp://ftp.sec.gov/edgar/data/1000097/0000919574-07-005211.txt";
StandardFileSystemManager fsMgr = new StandardFileSystemManager();
fsMgr.setCacheStrategy(CacheStrategy.ON_RESOLVE);
fsMgr.init();
if(!fsMgr.hasProvider("ftp")) { throw new ParserFileException("No ftp
provider"); }
FileObject reportFile = fsMgr.resolveFile(path);
if(!reportFile.exists()) { throw new ParserFileException("File does
not exist: " + path); }

This throws the ParserFileException every time.  If I don't do the
reportFile.exists() check, I get a runtime exception later when I
attempt to get the FIleContent's Stream.

Thank you,
Derrick Rice
Tufts University CS Engineering Senior

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message