Is it possible to create non blocking ReadableByteChannel from InputStream object?
Channel.newChannel(inputStream) - produces channel which could be blocked by blocked InputStream.read invocation
No it is not possible. See the Javadoc.
You may try to implement such a channel yourself, using 'Inputstream.avalable()' to avoid blocking. However, this method does not guarantee to return correct value, so you have to check the Inputstream implementation you use.
Are you sure you need non-blocking channel? Generally, it requires periodical polling to check arrival of data. Asynchronous channels, which invoke callbacks on data arrival, have more sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With