Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/io/ObjectInput.java
38829 views
/*1* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.io;2627/**28* ObjectInput extends the DataInput interface to include the reading of29* objects. DataInput includes methods for the input of primitive types,30* ObjectInput extends that interface to include objects, arrays, and Strings.31*32* @author unascribed33* @see java.io.InputStream34* @see java.io.ObjectOutputStream35* @see java.io.ObjectInputStream36* @since JDK1.137*/38public interface ObjectInput extends DataInput, AutoCloseable {39/**40* Read and return an object. The class that implements this interface41* defines where the object is "read" from.42*43* @return the object read from the stream44* @exception java.lang.ClassNotFoundException If the class of a serialized45* object cannot be found.46* @exception IOException If any of the usual Input/Output47* related exceptions occur.48*/49public Object readObject()50throws ClassNotFoundException, IOException;5152/**53* Reads a byte of data. This method will block if no input is54* available.55* @return the byte read, or -1 if the end of the56* stream is reached.57* @exception IOException If an I/O error has occurred.58*/59public int read() throws IOException;6061/**62* Reads into an array of bytes. This method will63* block until some input is available.64* @param b the buffer into which the data is read65* @return the actual number of bytes read, -1 is66* returned when the end of the stream is reached.67* @exception IOException If an I/O error has occurred.68*/69public int read(byte b[]) throws IOException;7071/**72* Reads into an array of bytes. This method will73* block until some input is available.74* @param b the buffer into which the data is read75* @param off the start offset of the data76* @param len the maximum number of bytes read77* @return the actual number of bytes read, -1 is78* returned when the end of the stream is reached.79* @exception IOException If an I/O error has occurred.80*/81public int read(byte b[], int off, int len) throws IOException;8283/**84* Skips n bytes of input.85* @param n the number of bytes to be skipped86* @return the actual number of bytes skipped.87* @exception IOException If an I/O error has occurred.88*/89public long skip(long n) throws IOException;9091/**92* Returns the number of bytes that can be read93* without blocking.94* @return the number of available bytes.95* @exception IOException If an I/O error has occurred.96*/97public int available() throws IOException;9899/**100* Closes the input stream. Must be called101* to release any resources associated with102* the stream.103* @exception IOException If an I/O error has occurred.104*/105public void close() throws IOException;106}107108109