various refinements to network implementation

The main idea is to make DatagramChannel and *SocketChannel behave in
a way that more closely matches the standard, e.g. allow binding
sockets to addresses without necessarily listening on those addresses
and accept null addresses where appropriate.  It also avoids multiple
redundant DNS lookups.

This commit also implements CharBuffer and BindException, and adds the
Readable interface.
This commit is contained in:
Joel Dice
2014-03-28 12:30:20 -06:00
parent 1e1fff58f8
commit 6e7149061c
19 changed files with 713 additions and 184 deletions

View File

@ -10,7 +10,21 @@
package java.io;
public abstract class Reader implements Closeable {
import java.nio.CharBuffer;
public abstract class Reader implements Closeable, Readable {
public int read(CharBuffer buffer) throws IOException {
int c = read(buffer.array(),
buffer.arrayOffset() + buffer.position(),
buffer.remaining());
if (c > 0) {
buffer.position(buffer.position() + c);
}
return c;
}
public int read() throws IOException {
char[] buffer = new char[1];
int c = read(buffer);