Example usage for org.apache.commons.vfs RandomAccessContent write

List of usage examples for org.apache.commons.vfs RandomAccessContent write

Introduction

In this page you can find the example usage for org.apache.commons.vfs RandomAccessContent write.

Prototype

void write(int b) throws IOException;

Source Link

Document

Writes to the output stream the eight low-order bits of the argument b.

Usage

From source file:functionalTests.vfsprovider.TestProActiveProviderAutoclosing.java

@Test
public void testRandomReadWriteAccessOpenWriteAutocloseGetPosWrite() throws Exception {
    final FileObject fo = openFileObject("out.txt");
    fo.createFile();/*w w w .  ja  v  a2 s.com*/
    final RandomAccessContent rac = openRandomAccessContent(fo, RandomAccessMode.READWRITE);
    try {
        rac.write("abc".getBytes());
        Thread.sleep(SLEEP_TIME);
        assertEquals("abc".getBytes().length, rac.getFilePointer());
        rac.write("def".getBytes());
    } finally {
        rac.close();
    }
    assertContentEquals(fo, "abcdef");
    fo.close();
}

From source file:functionalTests.vfsprovider.TestProActiveProviderAutoclosing.java

@Test
public void testRandomReadWriteAccessOpenWriteSeekAutocloseGetPosWrite() throws Exception {
    final FileObject fo = openFileObject("out.txt");
    fo.createFile();/*from   w w  w  . jav a2s  .  c om*/
    final RandomAccessContent rac = openRandomAccessContent(fo, RandomAccessMode.READWRITE);
    try {
        rac.write("abcdef".getBytes());
        rac.seek("abc".getBytes().length);
        Thread.sleep(SLEEP_TIME);
        assertEquals("abc".getBytes().length, rac.getFilePointer());
        rac.write("ghi".getBytes());
    } finally {
        rac.close();
    }
    assertContentEquals(fo, "abcghi");
    fo.close();
}

From source file:functionalTests.vfsprovider.TestProActiveProviderAutoclosing.java

@Test
public void testRandomReadWriteAccessOpenAutocloseWrite() throws Exception {
    final FileObject fo = openFileObject("out.txt");
    fo.createFile();// w  w w.  j a v  a  2 s  .c  o  m
    final RandomAccessContent rac = openRandomAccessContent(fo, RandomAccessMode.READWRITE);
    try {
        Thread.sleep(SLEEP_TIME);
        rac.write("test".getBytes());
    } finally {
        rac.close();
    }
    assertContentEquals(fo, "test");
    fo.close();
}