Code example for ReadableByteChannel

Methods: read

0
			ByteBuffer b = ByteBuffer.allocate(1);
			int num = 0;
			 
			nwLock.wantRead();
			 
			num=channel.read(b);
			if(num<=0){
				if(num==-1)
					nwLock.stopReading();
				return num;
			} 
					 
			b.flip();
			 
			return (0xff&(int)b.get());
			 
		}catch(InterruptedException e){
			throw new IOException(e);
		}finally{ 
			nwLock.doneRead();
		}