本文整理了Java中org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.readFully()
方法的一些代码示例,展示了ZipArchiveInputStream.readFully()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipArchiveInputStream.readFully()
方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipArchiveInputStream
类名称:ZipArchiveInputStream
方法名:readFully
暂无
代码示例来源:origin: org.apache.commons/commons-compress
private void readFully(final byte[] b) throws IOException {
readFully(b, 0);
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Fills the given array with the first local file header and
* deals with splitting/spanning markers that may prefix the first
* LFH.
*/
private void readFirstLocalFileHeader(final byte[] lfh) throws IOException {
readFully(lfh);
final ZipLong sig = new ZipLong(lfh);
if (sig.equals(ZipLong.DD_SIG)) {
throw new UnsupportedZipFeatureException(UnsupportedZipFeatureException.Feature.SPLITTING);
}
if (sig.equals(ZipLong.SINGLE_SEGMENT_SPLIT_MARKER)) {
// The archive is not really split as only one segment was
// needed in the end. Just skip over the marker.
final byte[] missedLfhBytes = new byte[4];
readFully(missedLfhBytes);
System.arraycopy(lfh, 4, lfh, 0, LFH_LEN - 4);
System.arraycopy(missedLfhBytes, 0, lfh, LFH_LEN - 4, 4);
}
}
代码示例来源:origin: org.apache.commons/commons-compress
System.arraycopy(suspectLocalFileHeader, off, magic, 0, Math.min(bytesInBuffer, magic.length));
if (bytesInBuffer < magic.length) {
readFully(magic, bytesInBuffer);
readFully(magic);
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Reads the stream until it find the "End of central directory
* record" and consumes it as well.
*/
private void skipRemainderOfArchive() throws IOException {
// skip over central directory. One LFH has been read too much
// already. The calculation discounts file names and extra
// data so it will be too short.
realSkip((long) entriesRead * CFH_LEN - LFH_LEN);
findEocdRecord();
realSkip((long) ZipFile.MIN_EOCD_SIZE - WORD /* signature */ - SHORT /* comment len */);
readFully(shortBuf);
// file comment
realSkip(ZipShort.getValue(shortBuf));
}
代码示例来源:origin: org.apache.commons/commons-compress
private void readDataDescriptor() throws IOException {
readFully(wordBuf);
ZipLong val = new ZipLong(wordBuf);
if (ZipLong.DD_SIG.equals(val)) {
// data descriptor with signature, skip sig
readFully(wordBuf);
val = new ZipLong(wordBuf);
}
current.entry.setCrc(val.getValue());
// if there is a ZIP64 extra field, sizes are eight bytes
// each, otherwise four bytes each. Unfortunately some
// implementations - namely Java7 - use eight bytes without
// using a ZIP64 extra field -
// https://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7073588
// just read 16 bytes and check whether bytes nine to twelve
// look like one of the signatures of what could follow a data
// descriptor (ignoring archive decryption headers for now).
// If so, push back eight bytes and assume sizes are four
// bytes, otherwise sizes are eight bytes each.
readFully(twoDwordBuf);
final ZipLong potentialSig = new ZipLong(twoDwordBuf, DWORD);
if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) {
pushback(twoDwordBuf, DWORD, DWORD);
current.entry.setCompressedSize(ZipLong.getValue(twoDwordBuf));
current.entry.setSize(ZipLong.getValue(twoDwordBuf, WORD));
} else {
current.entry.setCompressedSize(ZipEightByteInteger.getLongValue(twoDwordBuf));
current.entry.setSize(ZipEightByteInteger.getLongValue(twoDwordBuf, DWORD));
}
}
代码示例来源:origin: org.apache.commons/commons-compress
readFully(lfhBuf);
readFully(fileName);
current.entry.setName(entryEncoding.decode(fileName), fileName);
if (hasUTF8Flag) {
readFully(extraData);
current.entry.setExtra(extraData);
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Fills the given array with the first local file header and
* deals with splitting/spanning markers that may prefix the first
* LFH.
*/
private void readFirstLocalFileHeader(final byte[] lfh) throws IOException {
readFully(lfh);
final ZipLong sig = new ZipLong(lfh);
if (sig.equals(ZipLong.DD_SIG)) {
throw new UnsupportedZipFeatureException(UnsupportedZipFeatureException.Feature.SPLITTING);
}
if (sig.equals(ZipLong.SINGLE_SEGMENT_SPLIT_MARKER)) {
// The archive is not really split as only one segment was
// needed in the end. Just skip over the marker.
final byte[] missedLfhBytes = new byte[4];
readFully(missedLfhBytes);
System.arraycopy(lfh, 4, lfh, 0, LFH_LEN - 4);
System.arraycopy(missedLfhBytes, 0, lfh, LFH_LEN - 4, 4);
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Reads the stream until it find the "End of central directory
* record" and consumes it as well.
*/
private void skipRemainderOfArchive() throws IOException {
// skip over central directory. One LFH has been read too much
// already. The calculation discounts file names and extra
// data so it will be too short.
realSkip((long) entriesRead * CFH_LEN - LFH_LEN);
findEocdRecord();
realSkip((long) ZipFile.MIN_EOCD_SIZE - WORD /* signature */ - SHORT /* comment len */);
readFully(shortBuf);
// file comment
realSkip(ZipShort.getValue(shortBuf));
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
private void readDataDescriptor() throws IOException {
readFully(wordBuf);
ZipLong val = new ZipLong(wordBuf);
if (ZipLong.DD_SIG.equals(val)) {
// data descriptor with signature, skip sig
readFully(wordBuf);
val = new ZipLong(wordBuf);
}
current.entry.setCrc(val.getValue());
// if there is a ZIP64 extra field, sizes are eight bytes
// each, otherwise four bytes each. Unfortunately some
// implementations - namely Java7 - use eight bytes without
// using a ZIP64 extra field -
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7073588
// just read 16 bytes and check whether bytes nine to twelve
// look like one of the signatures of what could follow a data
// descriptor (ignoring archive decryption headers for now).
// If so, push back eight bytes and assume sizes are four
// bytes, otherwise sizes are eight bytes each.
readFully(twoDwordBuf);
final ZipLong potentialSig = new ZipLong(twoDwordBuf, DWORD);
if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) {
pushback(twoDwordBuf, DWORD, DWORD);
current.entry.setCompressedSize(ZipLong.getValue(twoDwordBuf));
current.entry.setSize(ZipLong.getValue(twoDwordBuf, WORD));
} else {
current.entry.setCompressedSize(ZipEightByteInteger.getLongValue(twoDwordBuf));
current.entry.setSize(ZipEightByteInteger.getLongValue(twoDwordBuf, DWORD));
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
readFully(lfhBuf);
readFully(fileName);
current.entry.setName(entryEncoding.decode(fileName), fileName);
if (hasUTF8Flag) {
readFully(extraData);
current.entry.setExtra(extraData);
内容来源于网络,如有侵权,请联系作者删除!