Remote File Systems

In browsing a remote file system, we have the directory listings provided by the web server.

Index of /newton

  Name                    Last modified       Size  Description
[DIR] Parent Directory        14-Sep-2001 15:41      -  
[DIR] doc/                    21-Feb-2000 00:15      -  
[DIR] experimental/           16-Oct-2001 17:05      -  
[DIR] nhex_wst/               02-Nov-2001 09:49      -  
[DIR] official/               16-Oct-2001 17:14      -  
Apache/1.3.9 Server at collective.cv.hp.com Port 80
Methods in UrlResourceServer parse these directory pages and extract the necessary information.
public class UrlResourceServer extends ResourceServerBasics {

    public Resource[] getResources(Category category) throws IOException {
        Iterator i = getFileURLs(getURL(category));
        List resources = new Vector();
        while (i.hasNext()) {
            resources.add(new UrlResource(this, (URL)i.next()));
        }
        return (Resource[])resources.toArray(new Resource[0]);
    }

    private Iterator getFileURLs(URL parentURL) throws IOException {
        Iterator i = extractHREFs(parentURL);
        List fileURLs = new Vector();
        while (i.hasNext()) {
            URL url = (URL)i.next();
            if (isFileURL(url)) {
                fileURLs.add(url);
            }
        }
        return fileURLs.iterator();
    }
}