当前位置: 首页>>代码示例>>Java>>正文


Java DataInput.skipBytes方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:17,代码来源:Res9patchStreamDecoder.java

示例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());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:25,代码来源:LittleEndianDataInputStreamTest.java

示例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;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:23,代码来源:PdxReaderImpl.java

示例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);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:GridmixRecord.java

示例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;
}
 
开发者ID:KyoriPowered,项目名称:nbt,代码行数:19,代码来源:TagIO.java

示例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);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:InternalDataSerializer.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:AbstractEntry.java

示例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");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:VerifyClassLinkage.java

示例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();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:7,代码来源:Utility.java

示例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);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:7,代码来源:SizingFlagDUnitTest.java

示例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();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:7,代码来源:Utility.java


注:本文中的java.io.DataInput.skipBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。