de.netseeker.ejoe.io
Class ChannelInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
de.netseeker.ejoe.io.ChannelInputStream
- public class ChannelInputStream
- extends java.io.FilterInputStream
This is a very ugly try to work around the following issue when using
Channel.newInputStream(): If the client closes the connection and we are
already reading from the blocking InputStream, that stream will simply throw
an IOException to notify us of the connection close. Because channel.isOpen()
as well as the corresponding socket methods will not immediately tell us that
the socket is closed we have no chance to decide if the IOException was
thrown because the socket was closed by client or if there occured an
IOException in the reader of the InputStream. To avoid that annoying issue we
use this FilterInputStream which just wraps all IOException into a
NonReadableChannelException to tell us that the socket is not readable
anymore.
- Author:
- netseeker
Fields inherited from class java.io.FilterInputStream |
in |
Method Summary |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ChannelInputStream
public ChannelInputStream(java.io.InputStream in)
- Parameters:
in
-
read
public int read()
throws java.io.IOException
- Throws:
java.io.IOException
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Throws:
java.io.IOException
read
public int read(byte[] b)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2005-2006 netseeker. All Rights Reserved.