NIO Examples

Documentation Contents
NIO
The examples in the following table show how to use the NIO APIs.

Source File Description
Grep.java Searches a list of files for lines that match a given regular-expression pattern. Demonstrates NIO mapped byte buffers, charsets, and regular expressions.
Sum.java Computes 16-bit checksums for a list of files. Uses NIO mapped byte buffers for speed.
TimeQuery.java Asks a list of hosts what time it is. Is a simple, blocking program that demonstrates NIO socket channels (connection and reading), buffer handling, charsets, and regular expressions.
TimeServer.java Listens for connections and tells callers what time it is. Is a simple, blocking program that demonstrates NIO socket channels (accepting and writing), buffer handling, charsets, and regular expressions.
Ping.java Connects to each of a list of hosts and measures the time required to complete the connection. Uses a selector and two additional threads to demonstrate non-blocking connects and the multithreaded use of a selector.
NBTimeServer.java Implements a non-blocking Internet time server.


Copyright © 2001 Sun Microsystems, Inc. All Rights Reserved.