public final class InMemoryFileSystem extends Object implements FileSystem, org.junit.rules.TestRule
SYSTEM| Constructor and Description |
|---|
InMemoryFileSystem() |
| Modifier and Type | Method and Description |
|---|---|
okio.Sink |
appendingSink(File file)
Writes to
file, appending if data is already present. |
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
void |
delete(File file)
Deletes
file if it exists. |
void |
deleteContents(File directory)
Recursively delete the contents of
directory. |
void |
ensureResourcesClosed() |
boolean |
exists(File file)
Returns true if
file exists on the file system. |
void |
rename(File from,
File to)
Renames
from to to. |
okio.Sink |
sink(File file)
Writes to
file, discarding any data already present. |
long |
size(File file)
Returns the number of bytes stored in
file, or 0 if it does not exist. |
okio.Source |
source(File file)
Reads from
file. |
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRulepublic void ensureResourcesClosed()
public okio.Source source(File file) throws FileNotFoundException
FileSystemfile.source in interface FileSystemFileNotFoundExceptionpublic okio.Sink sink(File file) throws FileNotFoundException
FileSystemfile, discarding any data already present. Creates parent directories if
necessary.sink in interface FileSystemFileNotFoundExceptionpublic okio.Sink appendingSink(File file) throws FileNotFoundException
FileSystemfile, appending if data is already present. Creates parent directories if
necessary.appendingSink in interface FileSystemFileNotFoundExceptionpublic void delete(File file) throws IOException
FileSystemfile if it exists. Throws if the file exists and cannot be deleted.delete in interface FileSystemIOExceptionpublic boolean exists(File file)
FileSystemfile exists on the file system.exists in interface FileSystempublic long size(File file)
FileSystemfile, or 0 if it does not exist.size in interface FileSystempublic void rename(File from, File to) throws IOException
FileSystemfrom to to. Throws if the file cannot be renamed.rename in interface FileSystemIOExceptionpublic void deleteContents(File directory) throws IOException
FileSystemdirectory. Throws an IOException if any file could
not be deleted, or if dir is not a readable directory.deleteContents in interface FileSystemIOExceptionCopyright © 2017. All Rights Reserved.