use of java.io.SequenceInputStream in project Bytecoder by mirkosertic.
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 jackrabbit-oak by apache.
the class OakBufferedIndexFile method flushBlob.
private void flushBlob() throws IOException {
if (blobModified) {
int n = (int) Math.min(blobSize, length - (long) index * blobSize);
InputStream in = new ByteArrayInputStream(blob, 0, n);
if (uniqueKey != null) {
in = new SequenceInputStream(in, new ByteArrayInputStream(uniqueKey));
}
Blob b = blobFactory.createBlob(in);
if (index < data.size()) {
data.set(index, b);
} else {
checkState(index == data.size());
data.add(b);
}
dataModified = true;
blobModified = false;
}
}
use of java.io.SequenceInputStream in project jackrabbit-oak by apache.
the class OakStreamingIndexFile method pushData.
private void pushData(InputStream in) throws IOException {
if (uniqueKey != null) {
in = new SequenceInputStream(in, new ByteArrayInputStream(uniqueKey));
}
blob = blobFactory.createBlob(in);
blobModified = true;
}
use of java.io.SequenceInputStream in project javacore by wang125631.
the class demo03 method merge02.
@SuppressWarnings("all")
public static // ʹ��SequenceInputStream�ϲ��ļ���
void merge02() throws IOException {
// �ҵ�(��)Ŀ���ļ�
File inFile1 = new File("D:/demo01.java");
File inFile2 = new File("D:/demo02.java");
File outFile = new File("D:/demo03.java");
// �������ݵ�����/���ͨ��
FileInputStream fileInputStream1 = new FileInputStream(inFile1);
FileInputStream fileInputStream2 = new FileInputStream(inFile2);
FileOutputStream fileOutputStream = new FileOutputStream(outFile);
// ��������������
SequenceInputStream sequenceInputStream = new SequenceInputStream(fileInputStream1, fileInputStream2);
byte[] buf = new byte[1024];
int length = 0;
while ((length = sequenceInputStream.read(buf)) != -1) {
fileOutputStream.write(buf, 0, length);
}
sequenceInputStream.close();
fileOutputStream.close();
}
use of java.io.SequenceInputStream in project h2database by h2database.
the class Recover method readBlobMap.
/**
* INTERNAL
*/
public static InputStream readBlobMap(Connection conn, long lobId, long precision) throws SQLException {
final PreparedStatement prep = conn.prepareStatement("SELECT DATA FROM INFORMATION_SCHEMA.LOB_BLOCKS " + "WHERE LOB_ID = ? AND SEQ = ? AND ? > 0");
prep.setLong(1, lobId);
// precision is currently not really used,
// it is just to improve readability of the script
prep.setLong(3, precision);
return new SequenceInputStream(new Enumeration<InputStream>() {
private int seq;
private byte[] data = fetch();
private byte[] fetch() {
try {
prep.setInt(2, seq++);
ResultSet rs = prep.executeQuery();
if (rs.next()) {
return rs.getBytes(1);
}
return null;
} catch (SQLException e) {
throw DbException.convert(e);
}
}
@Override
public boolean hasMoreElements() {
return data != null;
}
@Override
public InputStream nextElement() {
ByteArrayInputStream in = new ByteArrayInputStream(data);
data = fetch();
return in;
}
});
}
Aggregations