1. /*
  2. * @(#)ObjectInput.java 1.18 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.io;
  8. /**
  9. * ObjectInput extends the DataInput interface to include the reading of
  10. * objects. DataInput includes methods for the input of primitive types,
  11. * ObjectInput extends that interface to include objects, arrays, and Strings.
  12. *
  13. * @author unascribed
  14. * @version 1.18, 01/23/03
  15. * @see java.io.InputStream
  16. * @see java.io.ObjectOutputStream
  17. * @see java.io.ObjectInputStream
  18. * @since JDK1.1
  19. */
  20. public interface ObjectInput extends DataInput {
  21. /**
  22. * Read and return an object. The class that implements this interface
  23. * defines where the object is "read" from.
  24. *
  25. * @return the object read from the stream
  26. * @exception java.lang.ClassNotFoundException If the class of a serialized
  27. * object cannot be found.
  28. * @exception IOException If any of the usual Input/Output
  29. * related exceptions occur.
  30. */
  31. public Object readObject()
  32. throws ClassNotFoundException, IOException;
  33. /**
  34. * Reads a byte of data. This method will block if no input is
  35. * available.
  36. * @return the byte read, or -1 if the end of the
  37. * stream is reached.
  38. * @exception IOException If an I/O error has occurred.
  39. */
  40. public int read() throws IOException;
  41. /**
  42. * Reads into an array of bytes. This method will
  43. * block until some input is available.
  44. * @param b the buffer into which the data is read
  45. * @return the actual number of bytes read, -1 is
  46. * returned when the end of the stream is reached.
  47. * @exception IOException If an I/O error has occurred.
  48. */
  49. public int read(byte b[]) throws IOException;
  50. /**
  51. * Reads into an array of bytes. This method will
  52. * block until some input is available.
  53. * @param b the buffer into which the data is read
  54. * @param off the start offset of the data
  55. * @param len the maximum number of bytes read
  56. * @return the actual number of bytes read, -1 is
  57. * returned when the end of the stream is reached.
  58. * @exception IOException If an I/O error has occurred.
  59. */
  60. public int read(byte b[], int off, int len) throws IOException;
  61. /**
  62. * Skips n bytes of input.
  63. * @param n the number of bytes to be skipped
  64. * @return the actual number of bytes skipped.
  65. * @exception IOException If an I/O error has occurred.
  66. */
  67. public long skip(long n) throws IOException;
  68. /**
  69. * Returns the number of bytes that can be read
  70. * without blocking.
  71. * @return the number of available bytes.
  72. * @exception IOException If an I/O error has occurred.
  73. */
  74. public int available() throws IOException;
  75. /**
  76. * Closes the input stream. Must be called
  77. * to release any resources associated with
  78. * the stream.
  79. * @exception IOException If an I/O error has occurred.
  80. */
  81. public void close() throws IOException;
  82. }