1. /*
  2. * @(#)Channel.java 1.16 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.nio.channels;
  8. import java.io.IOException;
  9. /**
  10. * A nexus for I/O operations.
  11. *
  12. * <p> A channel represents an open connection to an entity such as a hardware
  13. * device, a file, a network socket, or a program component that is capable of
  14. * performing one or more distinct I/O operations, for example reading or
  15. * writing.
  16. *
  17. * <p> A channel is either open or closed. A channel is open upon creation,
  18. * and once closed it remains closed. Once a channel is closed, any attempt to
  19. * invoke an I/O operation upon it will cause a {@link ClosedChannelException}
  20. * to be thrown. Whether or not a channel is open may be tested by invoking
  21. * its {@link #isOpen isOpen} method.
  22. *
  23. * <p> Channels are, in general, intended to be safe for multithreaded access
  24. * as described in the specifications of the interfaces and classes that extend
  25. * and implement this interface.
  26. *
  27. *
  28. * @author Mark Reinhold
  29. * @author JSR-51 Expert Group
  30. * @version 1.16, 03/01/23
  31. * @since 1.4
  32. */
  33. public interface Channel {
  34. /**
  35. * Tells whether or not this channel is open. </p>
  36. *
  37. * @return <tt>true</tt> if, and only if, this channel is open
  38. */
  39. public boolean isOpen();
  40. /**
  41. * Closes this channel.
  42. *
  43. * <p> After a channel is closed, any further attempt to invoke I/O
  44. * operations upon it will cause a {@link ClosedChannelException} to be
  45. * thrown.
  46. *
  47. * <p> If this channel is already closed then invoking this method has no
  48. * effect.
  49. *
  50. * <p> This method may be invoked at any time. If some other thread has
  51. * already invoked it, however, then another invocation will block until
  52. * the first invocation is complete, after which it will return without
  53. * effect. </p>
  54. *
  55. * @throws IOException If an I/O error occurs
  56. */
  57. public void close() throws IOException;
  58. }