本文整理汇总了Java中libcore.io.BufferIterator类的典型用法代码示例。如果您正苦于以下问题:Java BufferIterator类的具体用法?Java BufferIterator怎么用?Java BufferIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BufferIterator类属于libcore.io包,在下文中一共展示了BufferIterator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeTimeZone
import libcore.io.BufferIterator; //导入依赖的package包/类
public static ZoneInfo makeTimeZone(String id, BufferIterator it) {
// Variable names beginning tzh_ correspond to those in "tzfile.h".
// Check tzh_magic.
if (it.readInt() != 0x545a6966) { // "TZif"
return null;
}
// Skip the uninteresting part of the header.
it.skip(28);
// Read the sizes of the arrays we're about to read.
int tzh_timecnt = it.readInt();
int tzh_typecnt = it.readInt();
it.skip(4); // Skip tzh_charcnt.
int[] transitions = new int[tzh_timecnt];
it.readIntArray(transitions, 0, transitions.length);
byte[] type = new byte[tzh_timecnt];
it.readByteArray(type, 0, type.length);
int[] gmtOffsets = new int[tzh_typecnt];
byte[] isDsts = new byte[tzh_typecnt];
for (int i = 0; i < tzh_typecnt; ++i) {
gmtOffsets[i] = it.readInt();
isDsts[i] = it.readByte();
// We skip the abbreviation index. This would let us provide historically-accurate
// time zone abbreviations (such as "AHST", "YST", and "AKST" for standard time in
// America/Anchorage in 1982, 1983, and 1984 respectively). ICU only knows the current
// names, though, so even if we did use this data to provide the correct abbreviations
// for en_US, we wouldn't be able to provide correct abbreviations for other locales,
// nor would we be able to provide correct long forms (such as "Yukon Standard Time")
// for any locale. (The RI doesn't do any better than us here either.)
it.skip(1);
}
return new ZoneInfo(id, transitions, type, gmtOffsets, isDsts);
}
示例2: ZipEntry
import libcore.io.BufferIterator; //导入依赖的package包/类
ZipEntry(byte[] cdeHdrBuf, InputStream cdStream) throws IOException {
Streams.readFully(cdStream, cdeHdrBuf, 0, cdeHdrBuf.length);
BufferIterator it = HeapBufferIterator.iterator(cdeHdrBuf, 0, cdeHdrBuf.length,
ByteOrder.LITTLE_ENDIAN);
int sig = it.readInt();
if (sig != CENSIG) {
ZipFile.throwZipException("Central Directory Entry", sig);
}
it.seek(8);
int gpbf = it.readShort() & 0xffff;
if ((gpbf & ZipFile.GPBF_UNSUPPORTED_MASK) != 0) {
throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
}
compressionMethod = it.readShort() & 0xffff;
time = it.readShort() & 0xffff;
modDate = it.readShort() & 0xffff;
// These are 32-bit values in the file, but 64-bit fields in this object.
crc = ((long) it.readInt()) & 0xffffffffL;
compressedSize = ((long) it.readInt()) & 0xffffffffL;
size = ((long) it.readInt()) & 0xffffffffL;
nameLength = it.readShort() & 0xffff;
int extraLength = it.readShort() & 0xffff;
int commentByteCount = it.readShort() & 0xffff;
// This is a 32-bit value in the file, but a 64-bit field in this object.
it.seek(42);
localHeaderRelOffset = ((long) it.readInt()) & 0xffffffffL;
byte[] nameBytes = new byte[nameLength];
Streams.readFully(cdStream, nameBytes, 0, nameBytes.length);
if (containsNulByte(nameBytes)) {
throw new ZipException("Filename contains NUL byte: " + Arrays.toString(nameBytes));
}
name = new String(nameBytes, 0, nameBytes.length, StandardCharsets.UTF_8);
if (extraLength > 0) {
extra = new byte[extraLength];
Streams.readFully(cdStream, extra, 0, extraLength);
}
// The RI has always assumed UTF-8. (If GPBF_UTF8_FLAG isn't set, the encoding is
// actually IBM-437.)
if (commentByteCount > 0) {
byte[] commentBytes = new byte[commentByteCount];
Streams.readFully(cdStream, commentBytes, 0, commentByteCount);
comment = new String(commentBytes, 0, commentBytes.length, StandardCharsets.UTF_8);
}
}
示例3: ZipEntry
import libcore.io.BufferIterator; //导入依赖的package包/类
ZipEntry(byte[] hdrBuf, InputStream in) throws IOException {
Streams.readFully(in, hdrBuf, 0, hdrBuf.length);
BufferIterator it = HeapBufferIterator.iterator(hdrBuf, 0, hdrBuf.length, ByteOrder.LITTLE_ENDIAN);
int sig = it.readInt();
if (sig != CENSIG) {
throw new ZipException("Central Directory Entry not found");
}
it.seek(8);
int gpbf = it.readShort() & 0xffff;
if ((gpbf & ZipFile.GPBF_UNSUPPORTED_MASK) != 0) {
throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
}
compressionMethod = it.readShort() & 0xffff;
time = it.readShort() & 0xffff;
modDate = it.readShort() & 0xffff;
// These are 32-bit values in the file, but 64-bit fields in this object.
crc = ((long) it.readInt()) & 0xffffffffL;
compressedSize = ((long) it.readInt()) & 0xffffffffL;
size = ((long) it.readInt()) & 0xffffffffL;
nameLength = it.readShort() & 0xffff;
int extraLength = it.readShort() & 0xffff;
int commentByteCount = it.readShort() & 0xffff;
// This is a 32-bit value in the file, but a 64-bit field in this object.
it.seek(42);
localHeaderRelOffset = ((long) it.readInt()) & 0xffffffffL;
byte[] nameBytes = new byte[nameLength];
Streams.readFully(in, nameBytes, 0, nameBytes.length);
if (containsNulByte(nameBytes)) {
throw new ZipException("Filename contains NUL byte: " + Arrays.toString(nameBytes));
}
name = new String(nameBytes, 0, nameBytes.length, StandardCharsets.UTF_8);
if (extraLength > 0) {
extra = new byte[extraLength];
Streams.readFully(in, extra, 0, extraLength);
}
// The RI has always assumed UTF-8. (If GPBF_UTF8_FLAG isn't set, the encoding is
// actually IBM-437.)
if (commentByteCount > 0) {
byte[] commentBytes = new byte[commentByteCount];
Streams.readFully(in, commentBytes, 0, commentByteCount);
comment = new String(commentBytes, 0, commentBytes.length, StandardCharsets.UTF_8);
}
}