Search in sources :

Example 61 with SequenceInputStream

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

the class OldSequenceInputStreamTest method test_readSkipsEmpty.

public void test_readSkipsEmpty() throws Exception {
    SequenceInputStream sequenceInputStream1 = createSequenceInputStreamWithGaps();
    for (int i = 0; i < s1.length(); i++) {
        assertEquals(s1.charAt(i), sequenceInputStream1.read());
    }
    for (int i = 0; i < s2.length(); i++) {
        assertEquals(s2.charAt(i), sequenceInputStream1.read());
    }
    assertEquals(-1, sequenceInputStream1.read());
}
Also used : SequenceInputStream(java.io.SequenceInputStream)

Example 62 with SequenceInputStream

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

the class OldSequenceInputStreamTest method setUp.

protected void setUp() {
    simple1 = new Support_ASimpleInputStream(s1);
    simple2 = new Support_ASimpleInputStream(s2);
    si = new SequenceInputStream(simple1, simple2);
}
Also used : SequenceInputStream(java.io.SequenceInputStream) Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream)

Example 63 with SequenceInputStream

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

the class OldSequenceInputStreamTest method test_readArraySkipsEmpty.

public void test_readArraySkipsEmpty() throws Exception {
    SequenceInputStream sequenceInputStream1 = createSequenceInputStreamWithGaps();
    byte[] buf = new byte[10];
    assertEquals(s1.length(), sequenceInputStream1.read(buf, 0, s1.length()));
    assertEquals(s1, new String(buf, 0, s1.length()));
    assertEquals(s2.length(), sequenceInputStream1.read(buf, 0, s2.length()));
    assertEquals(s2, new String(buf, 0, s2.length()));
    assertEquals(-1, sequenceInputStream1.read(buf, 0, s1.length()));
}
Also used : SequenceInputStream(java.io.SequenceInputStream)

Example 64 with SequenceInputStream

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

the class GZIPInputStream method readTrailer.

/*
     * Reads GZIP member trailer and returns true if the eos
     * reached, false if there are more (concatenated gzip
     * data set)
     */
private boolean readTrailer() throws IOException {
    InputStream in = this.in;
    int n = inf.getRemaining();
    if (n > 0) {
        in = new SequenceInputStream(new ByteArrayInputStream(buf, len - n, n), new FilterInputStream(in) {

            public void close() throws IOException {
            }
        });
    }
    // Uses left-to-right evaluation order
    if ((readUInt(in) != crc.getValue()) || // rfc1952; ISIZE is the input size modulo 2^32
    (readUInt(in) != (inf.getBytesWritten() & 0xffffffffL)))
        throw new ZipException("Corrupt GZIP trailer");
    // try concatenated case
    if (this.in.available() > 0 || n > 26) {
        // this.trailer
        int m = 8;
        try {
            // next.header
            m += readHeader(in);
        } catch (IOException ze) {
            // ignore any malformed, do nothing
            return true;
        }
        inf.reset();
        if (n > m)
            inf.setInput(buf, len - n + m, n - m);
        return false;
    }
    return true;
}
Also used : FilterInputStream(java.io.FilterInputStream) SequenceInputStream(java.io.SequenceInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FilterInputStream(java.io.FilterInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInputStream(java.io.SequenceInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 65 with SequenceInputStream

use of java.io.SequenceInputStream in project midpoint by Evolveum.

the class AuditInsertion method computeChecksum.

private String computeChecksum(byte[]... objects) {
    try {
        List<InputStream> list = new ArrayList<>();
        for (byte[] data : objects) {
            if (data == null) {
                continue;
            }
            list.add(new ByteArrayInputStream(data));
        }
        SequenceInputStream sis = new SequenceInputStream(Collections.enumeration(list));
        return DigestUtils.md5Hex(sis);
    } catch (IOException ex) {
        throw new SystemException(ex);
    }
}
Also used : SequenceInputStream(java.io.SequenceInputStream) SystemException(com.evolveum.midpoint.util.exception.SystemException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInputStream(java.io.SequenceInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

Aggregations

SequenceInputStream (java.io.SequenceInputStream)123 InputStream (java.io.InputStream)78 ByteArrayInputStream (java.io.ByteArrayInputStream)67 IOException (java.io.IOException)47 ArrayList (java.util.ArrayList)32 FileInputStream (java.io.FileInputStream)24 BufferedInputStream (java.io.BufferedInputStream)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 Vector (java.util.Vector)10 Test (org.junit.Test)10 FileOutputStream (java.io.FileOutputStream)9 List (java.util.List)9 lombok.val (lombok.val)9 File (java.io.File)8 OutputStream (java.io.OutputStream)8 HashMap (java.util.HashMap)8 InputStreamReader (java.io.InputStreamReader)7 ByteBuffer (java.nio.ByteBuffer)6 Support_ASimpleInputStream (tests.support.Support_ASimpleInputStream)6 Reader (java.io.Reader)5