Search in sources :

Example 1 with LineNumberInputStream

use of java.io.LineNumberInputStream in project jdk8u_jdk by JetBrains.

the class SkipEOL method main.

public static void main(String[] argv) throws Exception {
    byte[] data = { 12, 13, 10, 23, 11, 13, 12, 10, 13 };
    byte[] expected = { 12, 10, 23, 11, 10, 12, 10, 10 };
    LineNumberInputStream in = new LineNumberInputStream(new ByteArrayInputStream(data));
    // skip 3 bytes
    long skipped = in.skip(3);
    if ((skipped == 3) && ((in.read()) != 11)) {
        throw new RuntimeException("LineNumberInputStream.skip - " + "unexpected results!");
    }
    in = new LineNumberInputStream(new ByteArrayInputStream(data));
    for (int i = 0; i < 8; i++) {
        if (in.read() != expected[i]) {
            throw new RuntimeException("LineNumberInputStream.read - " + "unexpected results!");
        }
    }
    System.err.println("Test completed successfully");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LineNumberInputStream(java.io.LineNumberInputStream)

Example 2 with LineNumberInputStream

use of java.io.LineNumberInputStream in project j2objc by google.

the class OldLineNumberInputStreamTest method setUp.

protected void setUp() {
    /*
         * In order for IOException to be thrown in reset(),the inputStream to
         * the constructor cannot be a byteArrayInputstream because the reset()
         * in byteArrayInputStream does not throw IOException. When
         * BufferedInputStream is used, the size of the buffer must be smaller
         * than the readlimit in mark inorder for IOException to be thrown
         */
    BufferedInputStream buftemp = new BufferedInputStream(new ByteArrayInputStream(text.getBytes()), 4);
    lnis = new LineNumberInputStream(buftemp);
    lnis2 = new LineNumberInputStream(new ByteArrayInputStream(dosText.getBytes()));
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) LineNumberInputStream(java.io.LineNumberInputStream)

Example 3 with LineNumberInputStream

use of java.io.LineNumberInputStream in project robovm by robovm.

the class OldLineNumberInputStreamTest method setUp.

protected void setUp() {
    /*
         * In order for IOException to be thrown in reset(),the inputStream to
         * the constructor cannot be a byteArrayInputstream because the reset()
         * in byteArrayInputStream does not throw IOException. When
         * BufferedInputStream is used, the size of the buffer must be smaller
         * than the readlimit in mark inorder for IOException to be thrown
         */
    BufferedInputStream buftemp = new BufferedInputStream(new ByteArrayInputStream(text.getBytes()), 4);
    lnis = new LineNumberInputStream(buftemp);
    lnis2 = new LineNumberInputStream(new ByteArrayInputStream(dosText.getBytes()));
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) LineNumberInputStream(java.io.LineNumberInputStream)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)3 LineNumberInputStream (java.io.LineNumberInputStream)3 BufferedInputStream (java.io.BufferedInputStream)2