Package org.terrier.utility.io
Class ResourceFileSystem
- java.lang.Object
-
- org.terrier.utility.io.ResourceFileSystem
-
- All Implemented Interfaces:
FileSystem
public class ResourceFileSystem extends java.lang.Object implements FileSystem
Implements a read-only file system based on Java resources.- Since:
- 4.2
- Author:
- Craig Macdonald
-
-
Constructor Summary
Constructors Constructor Description ResourceFileSystem()
Create a new HTTPFileSystem
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRead(java.lang.String filename)
returns true if filename can be readboolean
canWrite(java.lang.String filename)
returns true if filename can be written tobyte
capabilities()
capabilities of the filesystemboolean
delete(java.lang.String filename)
delete the named fileboolean
deleteOnExit(java.lang.String pathname)
delete the file when the JVM exitsboolean
exists(java.lang.String filename)
returns true if the path existsjava.lang.String
getParent(java.lang.String path)
whats the parent path to this path - eg directory containing a fileboolean
isDirectory(java.lang.String path)
returns true if path is a directorylong
length(java.lang.String filename)
returns the length of the specified filejava.lang.String[]
list(java.lang.String path)
list contents of a directory etcboolean
mkdir(java.lang.String filename)
mkdir the specified pathjava.lang.String
name()
return the name of the file systemRandomDataInput
openFileRandom(java.lang.String filename)
open a file for random inputjava.io.InputStream
openFileStream(java.lang.String filename)
open a file of given filename for readingboolean
rename(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, httpsRandomDataOutput
writeFileRandom(java.lang.String filename)
open a file of given filename for random writingjava.io.OutputStream
writeFileStream(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:
name
in interfaceFileSystem
-
capabilities
public byte capabilities()
capabilities of the filesystem- Specified by:
capabilities
in interfaceFileSystem
-
schemes
public java.lang.String[] schemes()
URI schemes supported by this class: http, ftp, https- Specified by:
schemes
in interfaceFileSystem
-
exists
public boolean exists(java.lang.String filename) throws java.io.IOException
returns true if the path exists- Specified by:
exists
in interfaceFileSystem
- Throws:
java.io.IOException
-
openFileStream
public java.io.InputStream openFileStream(java.lang.String filename) throws java.io.IOException
open a file of given filename for reading- Specified by:
openFileStream
in 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:
openFileRandom
in interfaceFileSystem
- Throws:
java.io.IOException
-
writeFileStream
public java.io.OutputStream writeFileStream(java.lang.String filename) throws java.io.IOException
open a file of given filename for writing- Specified by:
writeFileStream
in 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:
writeFileRandom
in interfaceFileSystem
- Throws:
java.io.IOException
-
delete
public boolean delete(java.lang.String filename) throws java.io.IOException
delete the named file- Specified by:
delete
in interfaceFileSystem
- Throws:
java.io.IOException
-
deleteOnExit
public boolean deleteOnExit(java.lang.String pathname) throws java.io.IOException
delete the file when the JVM exits- Specified by:
deleteOnExit
in interfaceFileSystem
- Throws:
java.io.IOException
-
mkdir
public boolean mkdir(java.lang.String filename) throws java.io.IOException
mkdir the specified path- Specified by:
mkdir
in interfaceFileSystem
- Throws:
java.io.IOException
-
canRead
public boolean canRead(java.lang.String filename)
returns true if filename can be read- Specified by:
canRead
in interfaceFileSystem
-
canWrite
public boolean canWrite(java.lang.String filename)
returns true if filename can be written to- Specified by:
canWrite
in interfaceFileSystem
-
length
public long length(java.lang.String filename) throws java.io.IOException
returns the length of the specified file- Specified by:
length
in interfaceFileSystem
- Throws:
java.io.IOException
-
isDirectory
public boolean isDirectory(java.lang.String path) throws java.io.IOException
returns true if path is a directory- Specified by:
isDirectory
in interfaceFileSystem
- Throws:
java.io.IOException
-
rename
public boolean rename(java.lang.String source, java.lang.String destination) throws java.io.IOException
rename a file/dir to another name, on the same file system- Specified by:
rename
in interfaceFileSystem
- Throws:
java.io.IOException
-
getParent
public java.lang.String getParent(java.lang.String path) throws java.io.IOException
whats the parent path to this path - eg directory containing a file- Specified by:
getParent
in interfaceFileSystem
- Throws:
java.io.IOException
-
list
public java.lang.String[] list(java.lang.String path) throws java.io.IOException
list contents of a directory etc- Specified by:
list
in interfaceFileSystem
- Throws:
java.io.IOException
-
-