rt/emul/compact/src/main/java/java/io/ObjectInput.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 26 Feb 2013 16:54:16 +0100
changeset 772 d382dacfd73f
parent 601 emul/compact/src/main/java/java/io/ObjectInput.java@5198affdb915
permissions -rw-r--r--
Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
jaroslav@601
     1
/*
jaroslav@601
     2
 * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
jaroslav@601
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@601
     4
 *
jaroslav@601
     5
 * This code is free software; you can redistribute it and/or modify it
jaroslav@601
     6
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@601
     7
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@601
     8
 * particular file as subject to the "Classpath" exception as provided
jaroslav@601
     9
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@601
    10
 *
jaroslav@601
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@601
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@601
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@601
    14
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@601
    15
 * accompanied this code).
jaroslav@601
    16
 *
jaroslav@601
    17
 * You should have received a copy of the GNU General Public License version
jaroslav@601
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@601
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@601
    20
 *
jaroslav@601
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@601
    22
 * or visit www.oracle.com if you need additional information or have any
jaroslav@601
    23
 * questions.
jaroslav@601
    24
 */
jaroslav@601
    25
jaroslav@601
    26
package java.io;
jaroslav@601
    27
jaroslav@601
    28
/**
jaroslav@601
    29
 * ObjectInput extends the DataInput interface to include the reading of
jaroslav@601
    30
 * objects. DataInput includes methods for the input of primitive types,
jaroslav@601
    31
 * ObjectInput extends that interface to include objects, arrays, and Strings.
jaroslav@601
    32
 *
jaroslav@601
    33
 * @author  unascribed
jaroslav@601
    34
 * @see java.io.InputStream
jaroslav@601
    35
 * @see java.io.ObjectOutputStream
jaroslav@601
    36
 * @see java.io.ObjectInputStream
jaroslav@601
    37
 * @since   JDK1.1
jaroslav@601
    38
 */
jaroslav@601
    39
public interface ObjectInput extends DataInput, AutoCloseable {
jaroslav@601
    40
    /**
jaroslav@601
    41
     * Read and return an object. The class that implements this interface
jaroslav@601
    42
     * defines where the object is "read" from.
jaroslav@601
    43
     *
jaroslav@601
    44
     * @return the object read from the stream
jaroslav@601
    45
     * @exception java.lang.ClassNotFoundException If the class of a serialized
jaroslav@601
    46
     *      object cannot be found.
jaroslav@601
    47
     * @exception IOException If any of the usual Input/Output
jaroslav@601
    48
     * related exceptions occur.
jaroslav@601
    49
     */
jaroslav@601
    50
    public Object readObject()
jaroslav@601
    51
        throws ClassNotFoundException, IOException;
jaroslav@601
    52
jaroslav@601
    53
    /**
jaroslav@601
    54
     * Reads a byte of data. This method will block if no input is
jaroslav@601
    55
     * available.
jaroslav@601
    56
     * @return  the byte read, or -1 if the end of the
jaroslav@601
    57
     *          stream is reached.
jaroslav@601
    58
     * @exception IOException If an I/O error has occurred.
jaroslav@601
    59
     */
jaroslav@601
    60
    public int read() throws IOException;
jaroslav@601
    61
jaroslav@601
    62
    /**
jaroslav@601
    63
     * Reads into an array of bytes.  This method will
jaroslav@601
    64
     * block until some input is available.
jaroslav@601
    65
     * @param b the buffer into which the data is read
jaroslav@601
    66
     * @return  the actual number of bytes read, -1 is
jaroslav@601
    67
     *          returned when the end of the stream is reached.
jaroslav@601
    68
     * @exception IOException If an I/O error has occurred.
jaroslav@601
    69
     */
jaroslav@601
    70
    public int read(byte b[]) throws IOException;
jaroslav@601
    71
jaroslav@601
    72
    /**
jaroslav@601
    73
     * Reads into an array of bytes.  This method will
jaroslav@601
    74
     * block until some input is available.
jaroslav@601
    75
     * @param b the buffer into which the data is read
jaroslav@601
    76
     * @param off the start offset of the data
jaroslav@601
    77
     * @param len the maximum number of bytes read
jaroslav@601
    78
     * @return  the actual number of bytes read, -1 is
jaroslav@601
    79
     *          returned when the end of the stream is reached.
jaroslav@601
    80
     * @exception IOException If an I/O error has occurred.
jaroslav@601
    81
     */
jaroslav@601
    82
    public int read(byte b[], int off, int len) throws IOException;
jaroslav@601
    83
jaroslav@601
    84
    /**
jaroslav@601
    85
     * Skips n bytes of input.
jaroslav@601
    86
     * @param n the number of bytes to be skipped
jaroslav@601
    87
     * @return  the actual number of bytes skipped.
jaroslav@601
    88
     * @exception IOException If an I/O error has occurred.
jaroslav@601
    89
     */
jaroslav@601
    90
    public long skip(long n) throws IOException;
jaroslav@601
    91
jaroslav@601
    92
    /**
jaroslav@601
    93
     * Returns the number of bytes that can be read
jaroslav@601
    94
     * without blocking.
jaroslav@601
    95
     * @return the number of available bytes.
jaroslav@601
    96
     * @exception IOException If an I/O error has occurred.
jaroslav@601
    97
     */
jaroslav@601
    98
    public int available() throws IOException;
jaroslav@601
    99
jaroslav@601
   100
    /**
jaroslav@601
   101
     * Closes the input stream. Must be called
jaroslav@601
   102
     * to release any resources associated with
jaroslav@601
   103
     * the stream.
jaroslav@601
   104
     * @exception IOException If an I/O error has occurred.
jaroslav@601
   105
     */
jaroslav@601
   106
    public void close() throws IOException;
jaroslav@601
   107
}