本文整理匯總了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();
}
}