Commons VFS を使用して HTTP サーバーからファイルを参照および取得して、ディレクトリ参照機能を実装しようとしています。以下のコード スニペットを参照してください。
try {
StandardFileSystemManager manager = new StandardFileSystemManager();
manager.addProvider("http", new HttpFileProvider());
manager.setCacheStrategy(CacheStrategy.ON_CALL);
manager.setFilesCache(new SoftRefFilesCache());
FileObject fileObject = manager.resolveFile("http://localhost");
System.out.println(fileObject.getChildren());
} catch (FileSystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
しかし、このコードを実行すると、次の例外が発生します。
org.apache.commons.vfs.FileSystemException: Could not list the contents of "http://localhost/" because it is not a folder.
at org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:527)
at org.apache.commons.vfs.impl.DecoratedFileObject.getChildren(DecoratedFileObject.java:105)
at org.apache.commons.vfs.cache.OnCallRefreshFileObject.getChildren(OnCallRefreshFileObject.java:105)
at VFSClient.main(VFSClient.java:31)
ただし、サーバーは稼働しており、ディレクトリを参照できます。
このエラーの理由を誰か教えてもらえますか?