/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }