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

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

Introduction

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

Prototype

byte readByte() throws IOException;

Source Link

Document

Reads and returns one input byte.

Usage

From source file:functionalTests.vfsprovider.TestProActiveProviderAutoclosing.java

@Test
public void testRandomReadOnlyAccessOpenReadSeekAutocloseGetPosRead() throws Exception {
    final FileObject fo = openFileObject(TEST_FILENAME);
    final RandomAccessContent rac = openRandomAccessContent(fo, RandomAccessMode.READ);
    try {//  w w  w  .j a va 2s .c  o  m
        rac.readByte();
        rac.seek(TEST_FILE_A_CHARS_NUMBER);
        Thread.sleep(SLEEP_TIME);
        assertEquals(TEST_FILE_A_CHARS_NUMBER, rac.getFilePointer());
        assertTrue('b' == rac.readByte());
    } finally {
        rac.close();
    }
    fo.close();
}

From source file:functionalTests.vfsprovider.TestProActiveProviderAutoclosing.java

@Test
public void testRandomReadOnlyAccessOpenReadAutocloseRead() throws Exception {
    final FileObject fo = openFileObject(TEST_FILENAME);
    final RandomAccessContent rac = openRandomAccessContent(fo, RandomAccessMode.READ);
    try {/*from www .  j  av a2s . c  o  m*/
        for (int i = 0; i < TEST_FILE_A_CHARS_NUMBER; i++) {
            assertTrue('a' == rac.readByte());
        }
        Thread.sleep(SLEEP_TIME);
        for (int i = 0; i < TEST_FILE_B_CHARS_NUMBER; i++) {
            assertTrue('b' == rac.readByte());
        }
    } finally {
        rac.close();
    }
    fo.close();
}

From source file:functionalTests.vfsprovider.TestProActiveProviderAutoclosing.java

@Test
public void testRandomReadOnlyAccessOpenAutocloseRead() throws Exception {
    final FileObject fo = openFileObject(TEST_FILENAME);
    final RandomAccessContent rac = openRandomAccessContent(fo, RandomAccessMode.READ);
    try {/*from w  w  w.ja v  a2s. c  o m*/
        Thread.sleep(SLEEP_TIME);
        for (int i = 0; i < TEST_FILE_A_CHARS_NUMBER; i++) {
            assertTrue('a' == rac.readByte());
        }
    } finally {
        rac.close();
    }
    fo.close();
}