本文整理汇总了Java中java.io.DataInput.skipBytes方法的典型用法代码示例。如果您正苦于以下问题:Java DataInput.skipBytes方法的具体用法?Java DataInput.skipBytes怎么用?Java DataInput.skipBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataInput
的用法示例。
在下文中一共展示了DataInput.skipBytes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find9patchChunk
import java.io.DataInput; //导入方法依赖的package包/类
private void find9patchChunk(DataInput di) throws AndrolibException,
IOException {
di.skipBytes(8);
while (true) {
int size;
try {
size = di.readInt();
} catch (IOException ex) {
throw new CantFind9PatchChunk("Cant find nine patch chunk", ex);
}
if (di.readInt() == NP_CHUNK_TYPE) {
return;
}
di.skipBytes(size + 4);
}
}
示例2: testSkipBytes
import java.io.DataInput; //导入方法依赖的package包/类
public void testSkipBytes() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
/* Write out various test values NORMALLY */
out.write(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // 10 bytes of junk to skip
initializeData(out);
byte[] data = baos.toByteArray();
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data));
int bytesSkipped = 0;
while (bytesSkipped < 10) {
bytesSkipped += in.skipBytes(10 - bytesSkipped);
}
/* Read in various values in LITTLE ENDIAN FORMAT */
byte[] b = new byte[2];
in.readFully(b);
assertEquals(-100, b[0]);
assertEquals(100, b[1]);
assertTrue(in.readBoolean());
assertFalse(in.readBoolean());
}
示例3: createDis
import java.io.DataInput; //导入方法依赖的package包/类
private static PdxInputStream createDis(DataInput in, int len) throws IOException {
boolean isBBIS = in instanceof ByteBufferInputStream;
PdxInputStream bbis;
if (isBBIS) {
// Note, it is ok for our immutable bbis to wrap a mutable bbis
// because PdxReaderImpl is only used for a quick deserialization.
// PdxInstanceImpl has its own flavor of createDis since it can
// live longer.
bbis = new PdxInputStream((ByteBufferInputStream) in, len);
int bytesSkipped = in.skipBytes(len);
int bytesRemaining = len - bytesSkipped;
while (bytesRemaining > 0) {
in.readByte();
bytesRemaining--;
}
} else {
byte[] bytes = new byte[len];
in.readFully(bytes);
bbis = new PdxInputStream(bytes);
}
return bbis;
}
示例4: readFields
import java.io.DataInput; //导入方法依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
size = WritableUtils.readVInt(in);
int payload = size - WritableUtils.getVIntSize(size);
if (payload > Long.SIZE / Byte.SIZE) {
seed = in.readLong();
payload -= Long.SIZE / Byte.SIZE;
} else {
Arrays.fill(literal, (byte)0);
in.readFully(literal, 0, payload);
dib.reset(literal, 0, literal.length);
seed = dib.readLong();
payload = 0;
}
final int vBytes = in.skipBytes(payload);
if (vBytes != payload) {
throw new EOFException("Expected " + payload + ", read " + vBytes);
}
}
示例5: readDataInput
import java.io.DataInput; //导入方法依赖的package包/类
/**
* Reads a compound tag from {@code input}.
*
* @param input the input
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NonNull
public static CompoundTag readDataInput(@NonNull final DataInput input) throws IOException {
final TagType type = TagType.of(input.readByte());
if(type != TagType.COMPOUND) {
throw new IOException(String.format("Expected root tag to be a %s, was %s", TagType.COMPOUND, type));
}
input.skipBytes(input.readUnsignedShort()); // read empty name
final Tag tag = type.create();
tag.read(input, 0); // initial depth is zero
return (CompoundTag) tag;
}
示例6: skipByteArray
import java.io.DataInput; //导入方法依赖的package包/类
/**
* Reads and discards an array of <code>byte</code>s from a <code>DataInput</code>.
*
* @throws IOException A problem occurs while writing to <code>out</code>
*
* @see #writeByteArray(byte[], DataOutput)
*/
public static void skipByteArray(DataInput in) throws IOException {
InternalDataSerializer.checkIn(in);
int length = InternalDataSerializer.readArrayLength(in);
if (length != -1) {
in.skipBytes(length);
if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
logger.trace(LogMarker.SERIALIZER, "Skipped byte array of length {}", length);
}
}
}
示例7: skip
import java.io.DataInput; //导入方法依赖的package包/类
private static void skip(DataInput input, int bytes) throws IOException {
int skipped = input.skipBytes(bytes);
if (skipped != bytes) {
throw new IOException();
}
}
示例8: skip
import java.io.DataInput; //导入方法依赖的package包/类
private static void skip(DataInput input, int bytes) throws IOException {
int skipped = input.skipBytes(bytes);
if (skipped != bytes) {
throw new IOException("Truncated class file");
}
}
示例9: skipFully
import java.io.DataInput; //导入方法依赖的package包/类
static void skipFully(final DataInput file, final int length) throws IOException {
int total = file.skipBytes(length);
if (total != length) {
throw new EOFException();
}
}
示例10: fromData
import java.io.DataInput; //导入方法依赖的package包/类
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
sizeForSizer = in.readInt();
sizeForSerialization = in.readInt();
// We don't actually need these things.
in.skipBytes(sizeForSerialization);
}
示例11: skipFully
import java.io.DataInput; //导入方法依赖的package包/类
static void skipFully(final DataInput file, final int length) throws IOException {
int total = file.skipBytes(length);
if (total != length) {
throw new EOFException();
}
}