FileDocCategorySizeDatePackage
PushbackInputStreamTest.javaAPI DocAndroid 1.5 API1890Wed May 06 22:42:02 BST 2009android.core

PushbackInputStreamTest

public class PushbackInputStreamTest extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestPushbackInputStream()

        String str = "AbCdEfGhIjKlM\nOpQrStUvWxYz";
        ByteArrayInputStream aa = new ByteArrayInputStream(str.getBytes());
        ByteArrayInputStream ba = new ByteArrayInputStream(str.getBytes());
        ByteArrayInputStream ca = new ByteArrayInputStream(str.getBytes());

        PushbackInputStream a = new PushbackInputStream(aa, 7);
        try {
            a.unread("push".getBytes());
            assertEquals("pushAbCdEfGhIjKlM\nOpQrStUvWxYz", IOUtil.read(a));
        } finally {
            a.close();
        }

        PushbackInputStream b = new PushbackInputStream(ba, 9);
        try {
            b.unread('X");
            assertEquals("XAbCdEfGhI", IOUtil.read(b, 10));
        } finally {
            b.close();
        }

        PushbackInputStream c = new PushbackInputStream(ca);
        try {
            assertEquals("bdfhjl\nprtvxz", IOUtil.skipRead(c));
        } finally {
            c.close();
        }