Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: use NIO with System.in [duplicate]

Is it possible to use NIO with System.in?

I would like to somehow treat 'stdin' as a selectable channel. Has anyone found a way to do this?

like image 767
Justin Avatar asked Dec 16 '09 15:12

Justin


1 Answers

I don't know about a SelectableChannel, but you can convert an InputStream to a ReadableByteChannel with

using java.nio.channels.Channels;

...

ReadableByteChannel in = Channels.newChannel(System.in);
like image 157
Powerlord Avatar answered Oct 22 '22 01:10

Powerlord