當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。