public class LocalFilesManager extends Object implements FilesManager
Constructor and Description |
---|
LocalFilesManager() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all contents from this files manager.
|
protected byte[] |
createExchangeBuffer() |
boolean |
delete(String dirPath,
String name)
This method deletes the specified file.
|
boolean |
exists(String dirPath,
String name)
Tests whether a data exists for this filename.
|
protected char |
getFileSeparator() |
void |
initialize()
Initialize this files manager.
|
String[] |
list(String dirPath)
Returns an array of strings naming the files in the given directory.
|
void |
move(String dirPath,
String src,
String dst)
Moves a file as a new file.
|
InputStream |
read(String dirPath,
String name)
Reads the content of the specified file.
|
void |
shutdown()
Shutdown this files manager.
|
void |
write(String dirPath,
String name,
InputStream contents)
Writes the given contents to specified file.
|
public void clear() throws IOException
FilesManager
clear
in interface FilesManager
IOException
- If an I/O errors is occur.protected byte[] createExchangeBuffer()
public boolean delete(String dirPath, String name)
FilesManager
delete
in interface FilesManager
dirPath
- parent directory of the file to be deleted.name
- name of the file to be deleted.true
if the file was deleted, false
otherwise.public boolean exists(String dirPath, String name) throws IOException
FilesManager
exists
in interface FilesManager
dirPath
- parent directory of the file to be created.name
- the filename to check.true
if the given ID exists, false
otherwiseIOException
- if an I/O error occurs.protected char getFileSeparator()
public void initialize() throws IOException
FilesManager
initialize
in interface FilesManager
IOException
- If an I/O errors is occur.public String[] list(String dirPath) throws IOException
FilesManager
list
in interface FilesManager
dirPath
- the directory to list its contents.IOException
- if the file does not existpublic void move(String dirPath, String src, String dst) throws IOException
FilesManager
If a file is already stored with the given destination filename, it is overwritten. The given source filename must denote a file.
move
in interface FilesManager
dirPath
- parent directory of the file to be created.src
- the filename of the file to move.dst
- the filename destination of the new file.IOException
- if an I/O error occurs.public InputStream read(String dirPath, String name)
FilesManager
read
in interface FilesManager
dirPath
- parent directory of the file to be read.name
- name of the file to be read.null
if there no content.public void shutdown() throws IOException
FilesManager
shutdown
in interface FilesManager
IOException
- If an I/O errors is occur.public void write(String dirPath, String name, InputStream contents) throws IOException
FilesManager
The specified path is relative the root directory. The method creates all necessary parent directories.
write
in interface FilesManager
dirPath
- parent directory of the file to be created.name
- name of the file to be created.contents
- contents of the file to be created.IOException
- If an I/O errors is occur.