Stay organized with collections
Save and categorize content based on your preferences.
OptionalDataException
open class OptionalDataException : ObjectStreamException
Exception indicating the failure of an object read operation due to unread primitive data, or the end of data belonging to a serialized object in the stream. This exception may be thrown in two cases:
- An attempt was made to read an object when the next element in the stream is primitive data. In this case, the OptionalDataException's length field is set to the number of bytes of primitive data immediately readable from the stream, and the eof field is set to false.
- An attempt was made to read past the end of data consumable by a class-defined readObject or readExternal method. In this case, the OptionalDataException's eof field is set to true, and the length field is set to 0.
Summary
Properties |
Boolean |
True if there is no more data in the buffered part of the stream.
|
Int |
The number of bytes of primitive data available to be read in the current buffer.
|
Properties
eof
var eof: Boolean
True if there is no more data in the buffered part of the stream.
length
var length: Int
The number of bytes of primitive data available to be read in the current buffer.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# OptionalDataException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOptionalDataException\n=====================\n\n```\nopen class OptionalDataException : ObjectStreamException\n```\n\n|---|---|---|---|---|------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) |||||\n| | ↳ | [java.lang.Exception](../lang/Exception.html#) ||||\n| | | ↳ | [java.io.IOException](/reference/kotlin/java/io/IOException) |||\n| | | | ↳ | [java.io.ObjectStreamException](/reference/kotlin/java/io/ObjectStreamException) ||\n| | | | | ↳ | [java.io.OptionalDataException](#) |\n\nException indicating the failure of an object read operation due to unread primitive data, or the end of data belonging to a serialized object in the stream. This exception may be thrown in two cases:\n\n- An attempt was made to read an object when the next element in the stream is primitive data. In this case, the OptionalDataException's length field is set to the number of bytes of primitive data immediately readable from the stream, and the eof field is set to false.\n- An attempt was made to read past the end of data consumable by a class-defined readObject or readExternal method. In this case, the OptionalDataException's eof field is set to true, and the length field is set to 0.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| Properties ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [eof](#eof:kotlin.Boolean) True if there is no more data in the buffered part of the stream. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [length](#length:kotlin.Int) The number of bytes of primitive data available to be read in the current buffer. |\n\nProperties\n----------\n\n### eof\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nvar eof: Boolean\n```\n\nTrue if there is no more data in the buffered part of the stream. \n\n### length\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nvar length: Int\n```\n\nThe number of bytes of primitive data available to be read in the current buffer."]]