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());
}
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);
}
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()));
}
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;
}
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);
}
}
Aggregations