Example usage for android.support.v4.util AtomicFile getBaseFile

List of usage examples for android.support.v4.util AtomicFile getBaseFile

Introduction

In this page you can find the example usage for android.support.v4.util AtomicFile getBaseFile.

Prototype

public File getBaseFile() 

Source Link

Usage

From source file:io.nuclei.splice.ApplicationTest.java

public void testDeleteFile() throws Exception {
    String id = writeFile();//  www  .  ja  va2 s.co  m
    cleanup.add(id);
    Splice.with(getContext(), id).delete();
    FileRef ref = FileManager.newRef(id);
    AtomicFile file = FileManager.getAtomicFile(getContext(), ref);
    assertTrue(!file.getBaseFile().exists());
}

From source file:io.nuclei.splice.ApplicationTest.java

void validateFile(String id, int type) throws Exception {
    FileRef ref = FileManager.newRef(id);
    assertTrue(ref.type == type);/*w w  w . ja v a 2  s  .c  o  m*/

    AtomicFile file = FileManager.getAtomicFile(getContext(), ref);
    assertTrue(file.getBaseFile().exists());

    FileInputStream in = file.openRead();
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        FileManager.copy(in, out);
        assertTrue(CONTENT.equals(out.toString("UTF-8")));
    } finally {
        in.close();
    }
}