humble-video-noarch/src/main/java/io/humble/video/customio/ReadableWritableChannelHandler.java
public int read(byte[] buf, int size)
  {
    int ret = -1;
    if (mOpenStream == null || !(mOpenStream instanceof ReadableByteChannel))
      return -1;

    try
    {
      ReadableByteChannel channel = (ReadableByteChannel) mOpenStream;
      ByteBuffer buffer = ByteBuffer.allocate(size);
      ret = channel.read(buffer);
      if (ret > 0) {
        buffer.flip();
        buffer.get(buf, 0, ret);
      }
      return ret;
    }
    catch (IOException e)
    {
      log.error("Got IO exception reading from channel: {}; {}",
          mOpenStream, e);
      return -1;
    }
  }
public int read(byte[] buf, int size)
  {
    int ret = -1;
    if (mOpenStream == null || !(mOpenStream instanceof ReadableByteChannel))
      return -1;

    try
    {
      ReadableByteChannel channel = (ReadableByteChannel) mOpenStream;
      ByteBuffer buffer = ByteBuffer.allocate(size);
      ret = channel.read(buffer);
      if (ret > 0) {
        buffer.flip();
        buffer.get(buf, 0, ret);
      }
      return ret;
    }
    catch (IOException e)
    {
      log.error("Got IO exception reading from channel: {}; {}",
          mOpenStream, e);
      return -1;
    }
  }
public int read ( byte [ ] buf , int size ) { int ret = - 1 ; if ( mOpenStream == null || ! ( mOpenStream instanceof ReadableByteChannel ) ) return - 1 ; try { ReadableByteChannel channel = ( ReadableByteChannel ) mOpenStream ; ByteBuffer buffer = ByteBuffer . allocate ( size ) ; ret = channel . read ( buffer ) ; if ( ret > 0 ) { buffer . flip ( ) ; buffer . get ( buf , 0 , ret ) ; } return ret ; } catch ( IOException e ) { log . error ( "Got IO exception reading from channel: {}; {}" , mOpenStream , e ) ; return - 1 ; } }
{@inheritDoc}
{