Code example for SocketChannel

Methods: write

   * Perform a nonblocking write of the data in buffer; 
  public int write(ByteBuffer buffer) throws IOException {
    return socketChannel_.write(buffer);
   * Writes to the underlying output stream if not null. 
  public void write(byte[] buf, int off, int len) throws TTransportException {
    if ((socketChannel_.validOps() & SelectionKey.OP_WRITE) != SelectionKey.OP_WRITE) {
      throw new TTransportException(TTransportException.NOT_OPEN, 
        "Cannot write to write-only socket channel"); 
    try { 
      socketChannel_.write(ByteBuffer.wrap(buf, off, len));
    } catch (IOException iox) {
      throw new TTransportException(TTransportException.UNKNOWN, iox);
Contextual code suggestions in your IDE  Get Codota for Java