1. /*
  2. * @(#)ObjectInput.java 1.14 01/11/29
  3. *
  4. * Copyright 2002 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.14, 11/29/01
  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. * @exception java.lang.ClassNotFoundException If the class of a serialized
  26. * object cannot be found.
  27. * @exception IOException If any of the usual Input/Output
  28. * related exceptions occur.
  29. */
  30. public Object readObject()
  31. throws ClassNotFoundException, IOException;
  32. /**
  33. * Reads a byte of data. This method will block if no input is
  34. * available.
  35. * @return the byte read, or -1 if the end of the
  36. * stream is reached.
  37. * @exception IOException If an I/O error has occurred.
  38. */
  39. public int read() throws IOException;
  40. /**
  41. * Reads into an array of bytes. This method will
  42. * block until some input is available.
  43. * @param b the buffer into which the data is read
  44. * @return the actual number of bytes read, -1 is
  45. * returned when the end of the stream is reached.
  46. * @exception IOException If an I/O error has occurred.
  47. */
  48. public int read(byte b[]) throws IOException;
  49. /**
  50. * Reads into an array of bytes. This method will
  51. * block until some input is available.
  52. * @param b the buffer into which the data is read
  53. * @param off the start offset of the data
  54. * @param len the maximum number of bytes read
  55. * @return the actual number of bytes read, -1 is
  56. * returned when the end of the stream is reached.
  57. * @exception IOException If an I/O error has occurred.
  58. */
  59. public int read(byte b[], int off, int len) throws IOException;
  60. /**
  61. * Skips n bytes of input.
  62. * @param n the number of bytes to be skipped
  63. * @return the actual number of bytes skipped.
  64. * @exception IOException If an I/O error has occurred.
  65. */
  66. public long skip(long n) throws IOException;
  67. /**
  68. * Returns the number of bytes that can be read
  69. * without blocking.
  70. * @return the number of available bytes.
  71. */
  72. public int available() throws IOException;
  73. /**
  74. * Closes the input stream. Must be called
  75. * to release any resources associated with
  76. * the stream.
  77. * @exception IOException If an I/O error has occurred.
  78. */
  79. public void close() throws IOException;
  80. }