java.io.ObjectInputStream.checkReadPrimitiveTypes()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中java.io.ObjectInputStream.checkReadPrimitiveTypes()方法的一些代码示例,展示了ObjectInputStream.checkReadPrimitiveTypes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectInputStream.checkReadPrimitiveTypes()方法的具体详情如下:
包路径:java.io.ObjectInputStream
类名称:ObjectInputStream
方法名:checkReadPrimitiveTypes

ObjectInputStream.checkReadPrimitiveTypes介绍

[英]Checks to if it is ok to read primitive types from this stream at this point. One is not supposed to read primitive types when about to read an object, for example, so an exception has to be thrown.
[中]检查此时是否可以从此流中读取基元类型。例如,当要读取对象时,不应该读取基元类型,因此必须抛出异常。

代码示例

代码示例来源:origin: robovm/robovm

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: robovm/robovm

/**
 * Reads a single byte from the source stream and returns it as an integer
 * in the range from 0 to 255. Returns -1 if the end of the source stream
 * has been reached. Blocks if no input is available.
 *
 * @return the byte read or -1 if the end of the source stream has been
 *         reached.
 * @throws IOException
 *             if an error occurs while reading from this stream.
 */
@Override
public int read() throws IOException {
  checkReadPrimitiveTypes();
  return primitiveData.read();
}

代码示例来源:origin: robovm/robovm

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: robovm/robovm

/**
 * Skips {@code length} bytes on the source stream. This method should not
 * be used to skip bytes at any arbitrary position, just when reading
 * primitive data types (int, char etc).
 *
 * @param length
 *            the number of bytes to skip.
 * @return the number of bytes actually skipped.
 * @throws IOException
 *             if an error occurs while skipping bytes on the source stream.
 * @throws NullPointerException
 *             if the source stream is {@code null}.
 */
public int skipBytes(int length) throws IOException {
  // To be used with available. Ok to call if reading primitive buffer
  if (input == null) {
    throw new NullPointerException("source stream is null");
  }
  int offset = 0;
  while (offset < length) {
    checkReadPrimitiveTypes();
    long skipped = primitiveData.skip(length - offset);
    if (skipped == 0) {
      return offset;
    }
    offset += (int) skipped;
  }
  return length;
}

代码示例来源:origin: robovm/robovm

checkReadPrimitiveTypes();
if (primitiveData.available() > 0) {
  OptionalDataException e = new OptionalDataException();

代码示例来源:origin: MobiVM/robovm

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: ibinti/bugvm

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: com.gluonhq/robovm-rt

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: com.bugvm/bugvm-rt

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: FlexoVM/flexovm

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Override
public int available() throws IOException {
  // returns 0 if next data is an object, or N if reading primitive types
  checkReadPrimitiveTypes();
  return primitiveData.available();
}

代码示例来源:origin: com.jtransc/jtransc-rt

/**
 * Reads a single byte from the source stream and returns it as an integer
 * in the range from 0 to 255. Returns -1 if the end of the source stream
 * has been reached. Blocks if no input is available.
 *
 * @return the byte read or -1 if the end of the source stream has been
 * reached.
 * @throws IOException if an error occurs while reading from this stream.
 */
@Override
public int read() throws IOException {
  checkReadPrimitiveTypes();
  return primitiveData.read();
}

代码示例来源:origin: MobiVM/robovm

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: ibinti/bugvm

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Override
public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  JTranscArrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: com.gluonhq/robovm-rt

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: FlexoVM/flexovm

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

代码示例来源:origin: com.bugvm/bugvm-rt

@Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
  if (byteCount == 0) {
    return 0;
  }
  checkReadPrimitiveTypes();
  return primitiveData.read(buffer, byteOffset, byteCount);
}

相关文章

ObjectInputStream类方法