IT. Expert System.

Android Reference

ObjectInputStream


java.io

Class ObjectInputStream

    • Constructor Detail

      • ObjectInputStream

        protected ObjectInputStream()
                             throws IOException
        Constructs a new ObjectInputStream. This default constructor can be used by subclasses that do not want to use the public constructor if it allocates unneeded data.
        Throws:
        IOException - if an error occurs when creating this stream.
      • ObjectInputStream

        public ObjectInputStream(InputStream input)
                          throws StreamCorruptedException,
                                 IOException
        Constructs a new ObjectInputStream that reads from the InputStream input.
        Parameters:
        input - the non-null source InputStream to filter reads on.
        Throws:
        IOException - if an error occurs while reading the stream header.
        StreamCorruptedException - if the source stream does not contain serialized objects that can be read.
    • Method Detail

      • available

        public int available()
                      throws IOException
        Description copied from class: InputStream
        Returns an estimated number of bytes that can be read or skipped without blocking for more input.

        Note that this method provides such a weak guarantee that it is not very useful in practice.

        Firstly, the guarantee is "without blocking for more input" rather than "without blocking": a read may still block waiting for I/O to complete — the guarantee is merely that it won't have to wait indefinitely for data to be written. The result of this method should not be used as a license to do I/O on a thread that shouldn't be blocked.

        Secondly, the result is a conservative estimate and may be significantly smaller than the actual number of bytes available. In particular, an implementation that always returns 0 would be correct. In general, callers should only use this method if they'd be satisfied with treating the result as a boolean yes or no answer to the question "is there definitely data ready?".

        Thirdly, the fact that a given number of bytes is "available" does not guarantee that a read or skip will actually read or skip that many bytes: they may read or skip fewer.

        It is particularly important to realize that you must not use this method to size a container and assume that you can read the entirety of the stream without needing to resize the container. Such callers should probably write everything they read to a ByteArrayOutputStream and convert that to a byte array. Alternatively, if you're reading from a file, File.length() returns the current length of the file (though assuming the file's length can't change may be incorrect, reading a file is inherently racy).

        The default implementation of this method in InputStream always returns 0. Subclasses should override this method if they are able to indicate the number of bytes available.

        Specified by:
        available in interface ObjectInput
        Overrides:
        available in class InputStream
        Returns:
        the estimated number of bytes available
        Throws:
        IOException - if this stream is closed or an error occurs
      • enableResolveObject

        protected boolean enableResolveObject(boolean enable)
        Enables object replacement for this stream. By default this is not enabled. Only trusted subclasses (loaded with system class loader) are allowed to change this status.
        Parameters:
        enable - true to enable object replacement; false to disable it.
        Returns:
        the previous setting.
        See Also:
        resolveObject(java.lang.Object), ObjectOutputStream.enableReplaceObject(boolean)
      • read

        public int read()
                 throws IOException
        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.
        Specified by:
        read in interface ObjectInput
        Specified by:
        read in class InputStream
        Returns:
        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.
      • read

        public int read(byte[] buffer,
               int offset,
               int length)
                 throws IOException
        Reads at most length bytes from the source stream and stores them in byte array buffer starting at offset count. Blocks until count bytes have been read, the end of the source stream is detected or an exception is thrown.
        Specified by:
        read in interface ObjectInput
        Overrides:
        read in class InputStream
        Parameters:
        buffer - the array in which to store the bytes read.
        offset - the initial position in buffer to store the bytes read from the source stream.
        length - the maximum number of bytes to store in buffer.
        Returns:
        the number of bytes read or -1 if the end of the source input stream has been reached.
        Throws:
        IndexOutOfBoundsException - if offset < 0 or length < 0, or if offset + length is greater than the length of buffer.
        IOException - if an error occurs while reading from this stream.
        NullPointerException - if buffer is null.
      • readByte

        public byte readByte()
                      throws IOException
        Reads a byte (8 bit) from the source stream.
        Specified by:
        readByte in interface DataInput
        Returns:
        the byte value read from the source stream.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeByte(int)
      • readChar

        public char readChar()
                      throws IOException
        Reads a character (16 bit) from the source stream.
        Specified by:
        readChar in interface DataInput
        Returns:
        the char value read from the source stream.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeChar(int)
      • readDouble

        public double readDouble()
                          throws IOException
        Reads a double (64 bit) from the source stream.
        Specified by:
        readDouble in interface DataInput
        Returns:
        the double value read from the source stream.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeDouble(double)
      • readFields

        public ObjectInputStream.GetField readFields()
                                              throws IOException,
                                                     ClassNotFoundException,
                                                     NotActiveException
        Reads the persistent fields of the object that is currently being read from the source stream. The values read are stored in a GetField object that provides access to the persistent fields. This GetField object is then returned.
        Returns:
        the GetField object from which persistent fields can be accessed by name.
        Throws:
        ClassNotFoundException - if the class of an object being deserialized can not be found.
        IOException - if an error occurs while reading from this stream.
        NotActiveException - if this stream is currently not reading an object.
      • readFloat

        public float readFloat()
                        throws IOException
        Reads a float (32 bit) from the source stream.
        Specified by:
        readFloat in interface DataInput
        Returns:
        the float value read from the source stream.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeFloat(float)
      • readFully

        public void readFully(byte[] dst)
                       throws IOException
        Reads bytes from the source stream into the byte array dst. This method will block until dst.length bytes have been read.
        Specified by:
        readFully in interface DataInput
        Parameters:
        dst - the array in which to store the bytes read.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
      • readFully

        public void readFully(byte[] dst,
                     int offset,
                     int byteCount)
                       throws IOException
        Reads byteCount bytes from the source stream into the byte array dst.
        Specified by:
        readFully in interface DataInput
        Parameters:
        dst - the byte array in which to store the bytes read.
        offset - the initial position in dst to store the bytes read from the source stream.
        byteCount - the number of bytes to read.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
      • readInt

        public int readInt()
                    throws IOException
        Reads an integer (32 bit) from the source stream.
        Specified by:
        readInt in interface DataInput
        Returns:
        the integer value read from the source stream.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeInt(int)
      • readLine

        @Deprecated
        public String readLine()
                        throws IOException
        Deprecated. Use BufferedReader
        Reads the next line from the source stream. Lines are terminated by '\r', '\n', "\r\n" or an EOF.
        Specified by:
        readLine in interface DataInput
        Returns:
        the string read from the source stream.
        Throws:
        IOException - if an error occurs while reading from the source stream.
      • readLong

        public long readLong()
                      throws IOException
        Reads a long (64 bit) from the source stream.
        Specified by:
        readLong in interface DataInput
        Returns:
        the long value read from the source stream.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeLong(long)
      • readUnsignedByte

        public int readUnsignedByte()
                             throws IOException
        Reads an unsigned byte (8 bit) from the source stream.
        Specified by:
        readUnsignedByte in interface DataInput
        Returns:
        the unsigned byte value read from the source stream packaged in an integer.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeByte(int)
      • readUnsignedShort

        public int readUnsignedShort()
                              throws IOException
        Reads an unsigned short (16 bit) from the source stream.
        Specified by:
        readUnsignedShort in interface DataInput
        Returns:
        the unsigned short value read from the source stream packaged in an integer.
        Throws:
        EOFException - if the end of the input is reached before the read request can be satisfied.
        IOException - if an error occurs while reading from the source stream.
        See Also:
        DataOutput.writeShort(int)
      • registerValidation

        public void registerValidation(ObjectInputValidation object,
                              int priority)
                                throws NotActiveException,
                                       InvalidObjectException
        Registers a callback for post-deserialization validation of objects. It allows to perform additional consistency checks before the readObject() method of this class returns its result to the caller. This method can only be called from within the readObject() method of a class that implements "special" deserialization rules. It can be called multiple times. Validation callbacks are then done in order of decreasing priority, defined by priority.
        Parameters:
        object - an object that can validate itself by receiving a callback.
        priority - the validator's priority.
        Throws:
        InvalidObjectException - if object is null.
        NotActiveException - if this stream is currently not reading objects. In that case, calling this method is not allowed.
        See Also:
        ObjectInputValidation.validateObject()
      • skipBytes

        public int skipBytes(int length)
                      throws IOException
        Skips 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).
        Specified by:
        skipBytes in interface DataInput
        Parameters:
        length - the number of bytes to skip.
        Returns:
        the number of bytes actually skipped.
        Throws:
        IOException - if an error occurs while skipping bytes on the source stream.
        NullPointerException - if the source stream is null.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 126 / . Delta: 0.03901 с