Search in sources :

Example 1 with TFileWriter

use of net.java.truevfs.access.TFileWriter in project mage by magefree.

the class ZipFilesReadWriteTest method test_write.

@Test
public void test_write() {
    try {
        String zipPath = tempFolder.newFolder().getAbsolutePath();
        TFile fileWriteZip = new TFile(Paths.get(zipPath, "temp-images.zip", "DIR", "test.txt").toString());
        Assert.assertFalse(fileWriteZip.exists());
        Writer writer = new TFileWriter(fileWriteZip);
        try {
            writer.write("test text");
            writer.close();
            Assert.assertTrue(fileWriteZip.exists());
            TFileReader reader = new TFileReader(fileWriteZip);
            BufferedReader br = new BufferedReader(reader);
            Assert.assertEquals(br.readLine(), "test text");
            reader.close();
        } finally {
            TVFS.umount();
        }
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}
Also used : TFile(net.java.truevfs.access.TFile) TFileWriter(net.java.truevfs.access.TFileWriter) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) TFileReader(net.java.truevfs.access.TFileReader) Writer(java.io.Writer) TFileWriter(net.java.truevfs.access.TFileWriter) Test(org.junit.Test)

Aggregations

BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 TFile (net.java.truevfs.access.TFile)1 TFileReader (net.java.truevfs.access.TFileReader)1 TFileWriter (net.java.truevfs.access.TFileWriter)1 Test (org.junit.Test)1