Package org.terrier.utility.io
Class HTTPFileSystem
- java.lang.Object
-
- org.terrier.utility.io.HTTPFileSystem
-
- All Implemented Interfaces:
FileSystem
public class HTTPFileSystem extends java.lang.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
Constructors Constructor Description HTTPFileSystem()Create a new HTTPFileSystem
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRead(java.lang.String filename)returns true if filename can be readbooleancanWrite(java.lang.String filename)returns true if filename can be written tobytecapabilities()capabilities of the filesystembooleandelete(java.lang.String filename)delete the named filebooleandeleteOnExit(java.lang.String pathname)delete the file when the JVM exitsbooleanexists(java.lang.String filename)returns true if the path existsjava.lang.StringgetParent(java.lang.String path)whats the parent path to this path - eg directory containing a filebooleanisDirectory(java.lang.String path)returns true if path is a directorylonglength(java.lang.String filename)returns the length of the specified filejava.lang.String[]list(java.lang.String path)list contents of a directory etcbooleanmkdir(java.lang.String filename)mkdir the specified pathjava.lang.Stringname()return the name of the file systemRandomDataInputopenFileRandom(java.lang.String filename)open a file for random inputjava.io.InputStreamopenFileStream(java.lang.String filename)open a file of given filename for readingbooleanrename(java.lang.String source, java.lang.String destination)rename a file/dir to another name, on the same file systemjava.lang.String[]schemes()URI schemes supported by this class: http, ftp, httpsRandomDataOutputwriteFileRandom(java.lang.String filename)open a file of given filename for random writingjava.io.OutputStreamwriteFileStream(java.lang.String filename)open a file of given filename for writing
-
-
-
Method Detail
-
name
public java.lang.String name()
return the name of the file system- Specified by:
namein interfaceFileSystem
-
capabilities
public byte capabilities()
capabilities of the filesystem- Specified by:
capabilitiesin interfaceFileSystem
-
schemes
public java.lang.String[] schemes()
URI schemes supported by this class: http, ftp, https- Specified by:
schemesin interfaceFileSystem
-
exists
public boolean exists(java.lang.String filename) throws java.io.IOExceptionreturns true if the path exists- Specified by:
existsin interfaceFileSystem- Throws:
java.io.IOException
-
openFileStream
public java.io.InputStream openFileStream(java.lang.String filename) throws java.io.IOExceptionopen a file of given filename for reading- Specified by:
openFileStreamin interfaceFileSystem- Throws:
java.io.IOException
-
openFileRandom
public RandomDataInput openFileRandom(java.lang.String filename) throws java.io.IOException
open a file for random input- Specified by:
openFileRandomin interfaceFileSystem- Throws:
java.io.IOException
-
writeFileStream
public java.io.OutputStream writeFileStream(java.lang.String filename) throws java.io.IOExceptionopen a file of given filename for writing- Specified by:
writeFileStreamin interfaceFileSystem- Throws:
java.io.IOException
-
writeFileRandom
public RandomDataOutput writeFileRandom(java.lang.String filename) throws java.io.IOException
open a file of given filename for random writing- Specified by:
writeFileRandomin interfaceFileSystem- Throws:
java.io.IOException
-
delete
public boolean delete(java.lang.String filename) throws java.io.IOExceptiondelete the named file- Specified by:
deletein interfaceFileSystem- Throws:
java.io.IOException
-
deleteOnExit
public boolean deleteOnExit(java.lang.String pathname) throws java.io.IOExceptiondelete the file when the JVM exits- Specified by:
deleteOnExitin interfaceFileSystem- Throws:
java.io.IOException
-
mkdir
public boolean mkdir(java.lang.String filename) throws java.io.IOExceptionmkdir the specified path- Specified by:
mkdirin interfaceFileSystem- Throws:
java.io.IOException
-
canRead
public boolean canRead(java.lang.String filename)
returns true if filename can be read- Specified by:
canReadin interfaceFileSystem
-
canWrite
public boolean canWrite(java.lang.String filename)
returns true if filename can be written to- Specified by:
canWritein interfaceFileSystem
-
length
public long length(java.lang.String filename) throws java.io.IOExceptionreturns the length of the specified file- Specified by:
lengthin interfaceFileSystem- Throws:
java.io.IOException
-
isDirectory
public boolean isDirectory(java.lang.String path) throws java.io.IOExceptionreturns true if path is a directory- Specified by:
isDirectoryin interfaceFileSystem- Throws:
java.io.IOException
-
rename
public boolean rename(java.lang.String source, java.lang.String destination) throws java.io.IOExceptionrename a file/dir to another name, on the same file system- Specified by:
renamein interfaceFileSystem- Throws:
java.io.IOException
-
getParent
public java.lang.String getParent(java.lang.String path) throws java.io.IOExceptionwhats the parent path to this path - eg directory containing a file- Specified by:
getParentin interfaceFileSystem- Throws:
java.io.IOException
-
list
public java.lang.String[] list(java.lang.String path) throws java.io.IOExceptionlist contents of a directory etc- Specified by:
listin interfaceFileSystem- Throws:
java.io.IOException
-
-