public synchronized ByteList read(int number) throws IOException, BadDescriptorException { checkReadable(); ensureReadNonBuffered(); ByteList byteList = new ByteList(number); // TODO this should entry into error handling somewhere int bytesRead = descriptor.read(number, byteList); if (bytesRead == -1) { eof = true; } return byteList; }
public synchronized ByteList read(int number) throws IOException, BadDescriptorException { checkReadable(); ensureReadNonBuffered(); ByteList byteList = new ByteList(number); // TODO this should entry into error handling somewhere int bytesRead = descriptor.read(number, byteList); if (bytesRead == -1) { eof = true; } return byteList; }
public synchronized ByteList read(int number) throws IOException, BadDescriptorException { checkReadable(); ensureReadNonBuffered(); ByteList byteList = new ByteList(number); // TODO this should entry into error handling somewhere int bytesRead = descriptor.read(number, byteList); if (bytesRead == -1) { eof = true; } return byteList; }
public synchronized ByteList read(int number) throws IOException, BadDescriptorException { checkReadable(); ensureReadNonBuffered(); ByteList byteList = new ByteList(number); // TODO this should entry into error handling somewhere int bytesRead = descriptor.read(number, byteList); if (bytesRead == -1) { eof = true; } return byteList; }
int n = descriptor.read(tmpDst); if (n == -1) { eof = true;
int n = descriptor.read(tmpDst); if (n == -1) { eof = true;
int n = descriptor.read(tmpDst); if (n == -1) { eof = true;
int n = descriptor.read(tmpDst); if (n == -1) { eof = true;
final int n = descriptor.read(bytesToRead, dst); if (n == -1) { eof = true;
private ByteList doReceive(ThreadContext context, int length) { Ruby runtime = context.runtime; ByteBuffer buf = ByteBuffer.allocate(length); try { context.getThread().beforeBlockingCall(); int read = openFile.getMainStreamSafe().getDescriptor().read(buf); if (read == 0) return null; return new ByteList(buf.array(), 0, buf.position()); } catch (BadDescriptorException e) { throw runtime.newIOError("bad descriptor"); } catch (IOException e) { // All errors to sysread should be SystemCallErrors, but on a closed stream // Ruby returns an IOError. Java throws same exception for all errors so // we resort to this hack... if ("Socket not open".equals(e.getMessage())) { throw runtime.newIOError(e.getMessage()); } throw runtime.newSystemCallError(e.getMessage()); } finally { context.getThread().afterBlockingCall(); } }
private ByteList doReceive(ThreadContext context, int length) { Ruby runtime = context.runtime; ByteBuffer buf = ByteBuffer.allocate(length); try { context.getThread().beforeBlockingCall(); int read = openFile.getMainStreamSafe().getDescriptor().read(buf); if (read == 0) return null; return new ByteList(buf.array(), 0, buf.position()); } catch (BadDescriptorException e) { throw runtime.newIOError("bad descriptor"); } catch (IOException e) { // All errors to sysread should be SystemCallErrors, but on a closed stream // Ruby returns an IOError. Java throws same exception for all errors so // we resort to this hack... if ("Socket not open".equals(e.getMessage())) { throw runtime.newIOError(e.getMessage()); } throw runtime.newSystemCallError(e.getMessage()); } finally { context.getThread().afterBlockingCall(); } }
final int n = descriptor.read(bytesToRead, dst); if (n == -1) { eof = true;
final int n = descriptor.read(bytesToRead, dst); if (n == -1) { eof = true;
final int n = descriptor.read(bytesToRead, dst); if (n == -1) { eof = true;
/** * Perform a low-level read of the specified number of bytes into the specified * byte list. The incoming bytes will be appended to the byte list. This is * equivalent to the read(2) POSIX function, and like that function it * ignores read and write buffers defined elsewhere. * * @param number the number of bytes to read * @param byteList the byte list on which to append 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 org.jruby.util.ByteList */ public int read(int number, ByteList byteList) throws IOException, BadDescriptorException { checkOpen(); byteList.ensure(byteList.length() + number); int bytesRead = read(ByteBuffer.wrap(byteList.getUnsafeBytes(), byteList.begin() + byteList.length(), number)); if (bytesRead > 0) { byteList.length(byteList.length() + bytesRead); } return bytesRead; }
/** * Perform a low-level read of the specified number of bytes into the specified * byte list. The incoming bytes will be appended to the byte list. This is * equivalent to the read(2) POSIX function, and like that function it * ignores read and write buffers defined elsewhere. * * @param number the number of bytes to read * @param byteList the byte list on which to append 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 org.jruby.util.ByteList */ public int read(int number, ByteList byteList) throws IOException, BadDescriptorException { checkOpen(); byteList.ensure(byteList.length() + number); int bytesRead = read(ByteBuffer.wrap(byteList.getUnsafeBytes(), byteList.begin() + byteList.length(), number)); if (bytesRead > 0) { byteList.length(byteList.length() + bytesRead); } return bytesRead; }
/** * Perform a low-level read of the specified number of bytes into the specified * byte list. The incoming bytes will be appended to the byte list. This is * equivalent to the read(2) POSIX function, and like that function it * ignores read and write buffers defined elsewhere. * * @param number the number of bytes to read * @param byteList the byte list on which to append 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 org.jruby.util.ByteList */ public int read(int number, ByteList byteList) throws IOException, BadDescriptorException { checkOpen(); byteList.ensure(byteList.length() + number); int bytesRead = read(ByteBuffer.wrap(byteList.getUnsafeBytes(), byteList.begin() + byteList.length(), number)); if (bytesRead > 0) { byteList.length(byteList.length() + bytesRead); } return bytesRead; }
/** * Perform a low-level read of the specified number of bytes into the specified * byte list. The incoming bytes will be appended to the byte list. This is * equivalent to the read(2) POSIX function, and like that function it * ignores read and write buffers defined elsewhere. * * @param number the number of bytes to read * @param byteList the byte list on which to append 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 org.jruby.util.ByteList */ public int read(int number, ByteList byteList) throws IOException, BadDescriptorException { checkOpen(); byteList.ensure(byteList.length() + number); int bytesRead = read(ByteBuffer.wrap(byteList.getUnsafeBytes(), byteList.begin() + byteList.length(), number)); if (bytesRead > 0) { byteList.length(byteList.length() + bytesRead); } return bytesRead; }
int bytesRead = myOpenFile.getMainStreamSafe().getDescriptor().read(len, str.getByteList());
int bytesRead = myOpenFile.getMainStreamSafe().getDescriptor().read(len, str.getByteList());