⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e175. writing to a socketchannel.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
See also e173 Creating a Non-Blocking Socket. 
    // Create a direct buffer to get bytes from socket.
    // Direct buffers should be long-lived and be reused as much as possible.
    ByteBuffer buf = ByteBuffer.allocateDirect(1024);
    
    try {
        // Fill the buffer with the bytes to write;
        // see e160 Putting Bytes into a ByteBuffer
        buf.put((byte)0xFF);
    
        // Prepare the buffer for reading by the socket
        buf.flip();
    
        // Write bytes
        int numBytesWritten = socketChannel.write(buf);
    } catch (IOException e) {
        // Connection may have been closed
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -