jaroslav@601: /* jaroslav@601: * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. jaroslav@601: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@601: * jaroslav@601: * This code is free software; you can redistribute it and/or modify it jaroslav@601: * under the terms of the GNU General Public License version 2 only, as jaroslav@601: * published by the Free Software Foundation. Oracle designates this jaroslav@601: * particular file as subject to the "Classpath" exception as provided jaroslav@601: * by Oracle in the LICENSE file that accompanied this code. jaroslav@601: * jaroslav@601: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@601: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@601: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@601: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@601: * accompanied this code). jaroslav@601: * jaroslav@601: * You should have received a copy of the GNU General Public License version jaroslav@601: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@601: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@601: * jaroslav@601: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@601: * or visit www.oracle.com if you need additional information or have any jaroslav@601: * questions. jaroslav@601: */ jaroslav@601: jaroslav@601: package java.io; jaroslav@601: jaroslav@601: /** jaroslav@601: * ObjectInput extends the DataInput interface to include the reading of jaroslav@601: * objects. DataInput includes methods for the input of primitive types, jaroslav@601: * ObjectInput extends that interface to include objects, arrays, and Strings. jaroslav@601: * jaroslav@601: * @author unascribed jaroslav@601: * @see java.io.InputStream jaroslav@601: * @see java.io.ObjectOutputStream jaroslav@601: * @see java.io.ObjectInputStream jaroslav@601: * @since JDK1.1 jaroslav@601: */ jaroslav@601: public interface ObjectInput extends DataInput, AutoCloseable { jaroslav@601: /** jaroslav@601: * Read and return an object. The class that implements this interface jaroslav@601: * defines where the object is "read" from. jaroslav@601: * jaroslav@601: * @return the object read from the stream jaroslav@601: * @exception java.lang.ClassNotFoundException If the class of a serialized jaroslav@601: * object cannot be found. jaroslav@601: * @exception IOException If any of the usual Input/Output jaroslav@601: * related exceptions occur. jaroslav@601: */ jaroslav@601: public Object readObject() jaroslav@601: throws ClassNotFoundException, IOException; jaroslav@601: jaroslav@601: /** jaroslav@601: * Reads a byte of data. This method will block if no input is jaroslav@601: * available. jaroslav@601: * @return the byte read, or -1 if the end of the jaroslav@601: * stream is reached. jaroslav@601: * @exception IOException If an I/O error has occurred. jaroslav@601: */ jaroslav@601: public int read() throws IOException; jaroslav@601: jaroslav@601: /** jaroslav@601: * Reads into an array of bytes. This method will jaroslav@601: * block until some input is available. jaroslav@601: * @param b the buffer into which the data is read jaroslav@601: * @return the actual number of bytes read, -1 is jaroslav@601: * returned when the end of the stream is reached. jaroslav@601: * @exception IOException If an I/O error has occurred. jaroslav@601: */ jaroslav@601: public int read(byte b[]) throws IOException; jaroslav@601: jaroslav@601: /** jaroslav@601: * Reads into an array of bytes. This method will jaroslav@601: * block until some input is available. jaroslav@601: * @param b the buffer into which the data is read jaroslav@601: * @param off the start offset of the data jaroslav@601: * @param len the maximum number of bytes read jaroslav@601: * @return the actual number of bytes read, -1 is jaroslav@601: * returned when the end of the stream is reached. jaroslav@601: * @exception IOException If an I/O error has occurred. jaroslav@601: */ jaroslav@601: public int read(byte b[], int off, int len) throws IOException; jaroslav@601: jaroslav@601: /** jaroslav@601: * Skips n bytes of input. jaroslav@601: * @param n the number of bytes to be skipped jaroslav@601: * @return the actual number of bytes skipped. jaroslav@601: * @exception IOException If an I/O error has occurred. jaroslav@601: */ jaroslav@601: public long skip(long n) throws IOException; jaroslav@601: jaroslav@601: /** jaroslav@601: * Returns the number of bytes that can be read jaroslav@601: * without blocking. jaroslav@601: * @return the number of available bytes. jaroslav@601: * @exception IOException If an I/O error has occurred. jaroslav@601: */ jaroslav@601: public int available() throws IOException; jaroslav@601: jaroslav@601: /** jaroslav@601: * Closes the input stream. Must be called jaroslav@601: * to release any resources associated with jaroslav@601: * the stream. jaroslav@601: * @exception IOException If an I/O error has occurred. jaroslav@601: */ jaroslav@601: public void close() throws IOException; jaroslav@601: }