org.terrier.utility.io
Class HTTPFileSystem

java.lang.Object
  extended by org.terrier.utility.io.HTTPFileSystem
All Implemented Interfaces:
FileSystem

public class HTTPFileSystem
extends Object
implements FileSystem

Implements a read-only HTTP file system for Terrier. Files can be read directly from a URL

Since:
2.1
Author:
Craig Macdonald

Constructor Summary
HTTPFileSystem()
          Create a new HTTPFileSystem
 
Method Summary
 boolean canRead(String filename)
          returns true if filename can be read
 boolean canWrite(String filename)
          returns true if filename can be written to
 byte capabilities()
          capabilities of the filesystem
 boolean delete(String filename)
          delete the named file
 boolean deleteOnExit(String pathname)
          delete the file when the JVM exits
 boolean exists(String filename)
          returns true if the path exists
 String getParent(String path)
          whats the parent path to this path - eg directory containing a file
 boolean isDirectory(String path)
          returns true if path is a directory
 long length(String filename)
          returns the length of the specified file
 String[] list(String path)
          list contents of a directory etc
 boolean mkdir(String filename)
          mkdir the specified path
 String name()
          return the name of the file system
 RandomDataInput openFileRandom(String filename)
          open a file for random input
 InputStream openFileStream(String filename)
          open a file of given filename for reading
 boolean rename(String source, String destination)
          rename a file/dir to another name, on the same file system
 String[] schemes()
          URI schemes supported by this class: http, ftp, https
 RandomDataOutput writeFileRandom(String filename)
          open a file of given filename for random writing
 OutputStream writeFileStream(String filename)
          open a file of given filename for writing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPFileSystem

public HTTPFileSystem()
Create a new HTTPFileSystem

Method Detail

name

public String name()
return the name of the file system

Specified by:
name in interface FileSystem

capabilities

public byte capabilities()
capabilities of the filesystem

Specified by:
capabilities in interface FileSystem

schemes

public String[] schemes()
URI schemes supported by this class: http, ftp, https

Specified by:
schemes in interface FileSystem

exists

public boolean exists(String filename)
               throws IOException
returns true if the path exists

Specified by:
exists in interface FileSystem
Throws:
IOException

openFileStream

public InputStream openFileStream(String filename)
                           throws IOException
open a file of given filename for reading

Specified by:
openFileStream in interface FileSystem
Throws:
IOException

openFileRandom

public RandomDataInput openFileRandom(String filename)
                               throws IOException
open a file for random input

Specified by:
openFileRandom in interface FileSystem
Throws:
IOException

writeFileStream

public OutputStream writeFileStream(String filename)
                             throws IOException
open a file of given filename for writing

Specified by:
writeFileStream in interface FileSystem
Throws:
IOException

writeFileRandom

public RandomDataOutput writeFileRandom(String filename)
                                 throws IOException
open a file of given filename for random writing

Specified by:
writeFileRandom in interface FileSystem
Throws:
IOException

delete

public boolean delete(String filename)
               throws IOException
delete the named file

Specified by:
delete in interface FileSystem
Throws:
IOException

deleteOnExit

public boolean deleteOnExit(String pathname)
                     throws IOException
delete the file when the JVM exits

Specified by:
deleteOnExit in interface FileSystem
Throws:
IOException

mkdir

public boolean mkdir(String filename)
              throws IOException
mkdir the specified path

Specified by:
mkdir in interface FileSystem
Throws:
IOException

canRead

public boolean canRead(String filename)
returns true if filename can be read

Specified by:
canRead in interface FileSystem

canWrite

public boolean canWrite(String filename)
returns true if filename can be written to

Specified by:
canWrite in interface FileSystem

length

public long length(String filename)
            throws IOException
returns the length of the specified file

Specified by:
length in interface FileSystem
Throws:
IOException

isDirectory

public boolean isDirectory(String path)
                    throws IOException
returns true if path is a directory

Specified by:
isDirectory in interface FileSystem
Throws:
IOException

rename

public boolean rename(String source,
                      String destination)
               throws IOException
rename a file/dir to another name, on the same file system

Specified by:
rename in interface FileSystem
Throws:
IOException

getParent

public String getParent(String path)
                 throws IOException
whats the parent path to this path - eg directory containing a file

Specified by:
getParent in interface FileSystem
Throws:
IOException

list

public String[] list(String path)
              throws IOException
list contents of a directory etc

Specified by:
list in interface FileSystem
Throws:
IOException


Terrier 3.6. Copyright © 2004-2011 University of Glasgow