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.TestRule
public void ensureResourcesClosed()
public okio.Source source(File file) throws FileNotFoundException
FileSystem
file
.source
in interface FileSystem
FileNotFoundException
public okio.Sink sink(File file) throws FileNotFoundException
FileSystem
file
, discarding any data already present. Creates parent directories if
necessary.sink
in interface FileSystem
FileNotFoundException
public okio.Sink appendingSink(File file) throws FileNotFoundException
FileSystem
file
, appending if data is already present. Creates parent directories if
necessary.appendingSink
in interface FileSystem
FileNotFoundException
public void delete(File file) throws IOException
FileSystem
file
if it exists. Throws if the file exists and cannot be deleted.delete
in interface FileSystem
IOException
public boolean exists(File file) throws IOException
FileSystem
file
exists on the file system.exists
in interface FileSystem
IOException
public long size(File file)
FileSystem
file
, or 0 if it does not exist.size
in interface FileSystem
public void rename(File from, File to) throws IOException
FileSystem
from
to to
. Throws if the file cannot be renamed.rename
in interface FileSystem
IOException
public void deleteContents(File directory) throws IOException
FileSystem
directory
. Throws an IOException if any file could
not be deleted, or if dir
is not a readable directory.deleteContents
in interface FileSystem
IOException
Copyright © 2017. All rights reserved.