DirectoryManagerpublic class DirectoryManagerImpl extends Object implements DirectoryManager
| Constructor | Description |
|---|---|
DirectoryManagerImpl(Path baseDirectory,
Boolean readOnly) |
Constructor
|
| Modifier and Type | Method | Description |
|---|---|---|
long |
createFile(String fileName,
InputStream inputStream) |
Creates a new file in the current directory, and fill it with the data
from the given input stream.
|
void |
createFile(String fileName,
String fileContents) |
Creates a new file in the current directory, and fill it with the given
data, encoded in UTF-8.
|
long |
createFileAtomic(String fileName,
InputStream inputStream) |
Creates a new file in the current directory, and fill it with the data
from the given input stream.
|
protected InputStream |
getCompressorInputStream(InputStream inputStream,
CompressionType compressionType) |
Returns an input stream that applies the required decompression to the
given input stream.
|
InputStream |
getInputStreamForFile(String fileName,
CompressionType compressionType) |
Returns an input stream to access file of the given name within the
current directory, possibly uncompressing it if required.
|
OutputStream |
getOutputStreamForFile(String fileName) |
Opens and returns an output stream that can be used to write to the file
of the given name within the current directory.
|
List<String> |
getSubdirectories(String glob) |
Returns a list of the names of all subdirectories of the base directory.
|
DirectoryManager |
getSubdirectoryManager(String subdirectoryName) |
Returns a new directory manager for the subdirectory of the given name.
|
boolean |
hasFile(String fileName) |
Checks if there is a file of the given name.
|
boolean |
hasSubdirectory(String subdirectoryName) |
Checks if there is a subdirectory of the given name.
|
String |
toString() |
public DirectoryManagerImpl(Path baseDirectory, Boolean readOnly) throws IOException
baseDirectory - the directory where the file manager should point initially;
will be created if not existingreadOnly - if false, the directory manager will attempt to create
directories when changing to a location that does not existIOException - if there was a problem creating the directorypublic DirectoryManager getSubdirectoryManager(String subdirectoryName) throws IOException
DirectoryManagerDirectoryManager.hasSubdirectory(String) first (ignoring the fact that there
might be race conditions when accessing the file system).getSubdirectoryManager in interface DirectoryManagersubdirectoryName - the string name of the subdirectoryIOException - if directory could not be createdpublic boolean hasSubdirectory(String subdirectoryName)
DirectoryManagerhasSubdirectory in interface DirectoryManagersubdirectoryName - the name of the subdirectorypublic boolean hasFile(String fileName)
DirectoryManagerhasFile in interface DirectoryManagerfileName - the name of the filepublic long createFile(String fileName, InputStream inputStream) throws IOException
DirectoryManagercreateFile in interface DirectoryManagerfileName - the name of the fileinputStream - the input stream from which to load the fileIOExceptionpublic long createFileAtomic(String fileName, InputStream inputStream) throws IOException
DirectoryManagerIf the stream encodes a string, then it should generally be encoded in UTF-8, since access methods assume this.
createFileAtomic in interface DirectoryManagerfileName - the name of the fileinputStream - the input stream from which to load the fileIOExceptionpublic void createFile(String fileName, String fileContents) throws IOException
DirectoryManagercreateFile in interface DirectoryManagerfileName - the name of the filefileContents - the data to write into the fileIOExceptionpublic OutputStream getOutputStreamForFile(String fileName) throws IOException
DirectoryManagergetOutputStreamForFile in interface DirectoryManagerfileName - the name of the fileIOExceptionpublic InputStream getInputStreamForFile(String fileName, CompressionType compressionType) throws IOException
DirectoryManagerIt is important to close the stream after using it to free memory.
getInputStreamForFile in interface DirectoryManagerfileName - the name of the filecompressionType - for types other than CompressionType.NONE, the file
will be uncompressed appropriately and the returned input
stream will provide access to the uncompressed contentIOExceptionprotected InputStream getCompressorInputStream(InputStream inputStream, CompressionType compressionType) throws IOException
inputStream - the input stream with the (possibly compressed) datacompressionType - the kind of compressionIOException - if there was a problem creating the decompression streamspublic List<String> getSubdirectories(String glob) throws IOException
DirectoryManagergetSubdirectories in interface DirectoryManagerglob - pattern to filter directoy namesIOExceptionCopyright © 2014–2017 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage