KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > nio > channels > Channel


1 /*
2  * @(#)Channel.java 1.18 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.nio.channels;
9
10 import java.io.IOException JavaDoc;
11 import java.io.Closeable JavaDoc;
12
13
14 /**
15  * A nexus for I/O operations.
16  *
17  * <p> A channel represents an open connection to an entity such as a hardware
18  * device, a file, a network socket, or a program component that is capable of
19  * performing one or more distinct I/O operations, for example reading or
20  * writing.
21  *
22  * <p> A channel is either open or closed. A channel is open upon creation,
23  * and once closed it remains closed. Once a channel is closed, any attempt to
24  * invoke an I/O operation upon it will cause a {@link ClosedChannelException}
25  * to be thrown. Whether or not a channel is open may be tested by invoking
26  * its {@link #isOpen isOpen} method.
27  *
28  * <p> Channels are, in general, intended to be safe for multithreaded access
29  * as described in the specifications of the interfaces and classes that extend
30  * and implement this interface.
31  *
32  *
33  * @author Mark Reinhold
34  * @author JSR-51 Expert Group
35  * @version 1.18, 03/12/19
36  * @since 1.4
37  */

38
39 public interface Channel extends Closeable JavaDoc {
40
41     /**
42      * Tells whether or not this channel is open. </p>
43      *
44      * @return <tt>true</tt> if, and only if, this channel is open
45      */

46     public boolean isOpen();
47
48     /**
49      * Closes this channel.
50      *
51      * <p> After a channel is closed, any further attempt to invoke I/O
52      * operations upon it will cause a {@link ClosedChannelException} to be
53      * thrown.
54      *
55      * <p> If this channel is already closed then invoking this method has no
56      * effect.
57      *
58      * <p> This method may be invoked at any time. If some other thread has
59      * already invoked it, however, then another invocation will block until
60      * the first invocation is complete, after which it will return without
61      * effect. </p>
62      *
63      * @throws IOException If an I/O error occurs
64      */

65     public void close() throws IOException JavaDoc;
66
67 }
68
Popular Tags