Sdílet prostřednictvím


IDataInput Interface

Definition

The DataInput interface provides for reading bytes from a binary stream and reconstructing from them data in any of the Java primitive types.

[Android.Runtime.Register("java/io/DataInput", "", "Java.IO.IDataInputInvoker")]
public interface IDataInput : Android.Runtime.IJavaObject, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("java/io/DataInput", "", "Java.IO.IDataInputInvoker")>]
type IDataInput = interface
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Derived
Attributes
Implements

Remarks

The DataInput interface provides for reading bytes from a binary stream and reconstructing from them data in any of the Java primitive types. There is also a facility for reconstructing a String from data in modified UTF-8 format.

It is generally true of all the reading routines in this interface that if end of file is reached before the desired number of bytes has been read, an EOFException (which is a kind of IOException) is thrown. If any byte cannot be read for any reason other than end of file, an IOException other than EOFException is thrown. In particular, an IOException may be thrown if the input stream has been closed.

<h3>"modified-utf-8">Modified UTF-8</h3>

Implementations of the DataInput and DataOutput interfaces represent Unicode strings in a format that is a slight modification of UTF-8. (For information regarding the standard UTF-8 format, see section 3.9 Unicode Encoding Forms of The Unicode Standard, Version 4.0)

<ul> <li>Characters in the range '\u005Cu0001' to '\u005Cu007F' are represented by a single byte. <li>The null character '\u005Cu0000' and characters in the range '\u005Cu0080' to '\u005Cu07FF' are represented by a pair of bytes. <li>Characters in the range '\u005Cu0800' to '\u005CuFFFF' are represented by three bytes. </ul>

<table class="plain" style="margin-left:2em;"> <caption>Encoding of UTF-8 values</caption> <thead> <tr> <th scope="col" rowspan="2">Value</th> <th scope="col" rowspan="2">Byte</th> <th scope="col" colspan="8" id="bit_a">Bit Values</th> </tr> <tr> <!-- Value --> <!-- Byte --> <th scope="col" style="width:3em"> 7 </th> <th scope="col" style="width:3em"> 6 </th> <th scope="col" style="width:3em"> 5 </th> <th scope="col" style="width:3em"> 4 </th> <th scope="col" style="width:3em"> 3 </th> <th scope="col" style="width:3em"> 2 </th> <th scope="col" style="width:3em"> 1 </th> <th scope="col" style="width:3em"> 0 </th> </thead> <tbody> <tr> <th scope="row" style="text-align:left; font-weight:normal"> \u005Cu0001 to \u005Cu007F</th> <th scope="row" style="font-weight:normal; text-align:center"> 1 </th> <td style="text-align:center">0 <td colspan="7" style="text-align:right; padding-right:6em">bits 6-0 </tr> <tr> <th scope="row" rowspan="2" style="text-align:left; font-weight:normal"> \u005Cu0000,<br> \u005Cu0080 to \u005Cu07FF</th> <th scope="row" style="font-weight:normal; text-align:center"> 1 </th> <td style="text-align:center">1 <td style="text-align:center">1 <td style="text-align:center">0 <td colspan="5" style="text-align:right; padding-right:6em">bits 10-6 </tr> <tr> <!-- (value) --> <th scope="row" style="font-weight:normal; text-align:center"> 2 </th> <td style="text-align:center">1 <td style="text-align:center">0 <td colspan="6" style="text-align:right; padding-right:6em">bits 5-0 </tr> <tr> <th scope="row" rowspan="3" style="text-align:left; font-weight:normal"> \u005Cu0800 to \u005CuFFFF</th> <th scope="row" style="font-weight:normal; text-align:center"> 1 </th> <td style="text-align:center">1 <td style="text-align:center">1 <td style="text-align:center">1 <td style="text-align:center">0 <td colspan="4" style="text-align:right; padding-right:6em">bits 15-12 </tr> <tr> <!-- (value) --> <th scope="row" style="font-weight:normal; text-align:center"> 2 </th> <td style="text-align:center">1 <td style="text-align:center">0 <td colspan="6" style="text-align:right; padding-right:6em">bits 11-6 </tr> <tr> <!-- (value) --> <th scope="row" style="font-weight:normal; text-align:center"> 3 </th> <td style="text-align:center">1 <td style="text-align:center">0 <td colspan="6" style="text-align:right; padding-right:6em">bits 5-0 </tr> </tbody> </table>

The differences between this format and the standard UTF-8 format are the following: <ul> <li>The null byte '\u005Cu0000' is encoded in 2-byte format rather than 1-byte, so that the encoded strings never have embedded nulls. <li>Only the 1-byte, 2-byte, and 3-byte formats are used. <li>Supplementary characters are represented in the form of surrogate pairs. </ul>

Added in 1.0.

Java documentation for java.io.DataInput.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
ReadBoolean()

Reads one input byte and returns true if that byte is nonzero, false if that byte is zero.

ReadByte()

Reads and returns one input byte.

ReadChar()

Reads two input bytes and returns a char value.

ReadDouble()

Reads eight input bytes and returns a double value.

ReadFloat()

Reads four input bytes and returns a float value.

ReadFully(Byte[], Int32, Int32)

Reads len bytes from an input stream.

ReadFully(Byte[])

Reads some bytes from an input stream and stores them into the buffer array b.

ReadInt()

Reads four input bytes and returns an int value.

ReadLine()

Reads the next line of text from the input stream.

ReadLong()

Reads eight input bytes and returns a long value.

ReadShort()

Reads two input bytes and returns a short value.

ReadUnsignedByte()

Reads one input byte, zero-extends it to type int, and returns the result, which is therefore in the range 0 through 255.

ReadUnsignedShort()

Reads two input bytes and returns an int value in the range 0 through 65535.

ReadUTF()

Reads in a string that has been encoded using a modified UTF-8 format.

SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
SkipBytes(Int32)

Makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes.

UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
ReadBooleanAsync(IDataInput)
ReadByteAsync(IDataInput)
ReadCharAsync(IDataInput)
ReadDoubleAsync(IDataInput)
ReadFloatAsync(IDataInput)
ReadFullyAsync(IDataInput, Byte[], Int32, Int32)
ReadFullyAsync(IDataInput, Byte[])
ReadIntAsync(IDataInput)
ReadLineAsync(IDataInput)
ReadLongAsync(IDataInput)
ReadShortAsync(IDataInput)
ReadUnsignedByteAsync(IDataInput)
ReadUnsignedShortAsync(IDataInput)
ReadUTFAsync(IDataInput)
SkipBytesAsync(IDataInput, Int32)

Applies to