為了使讀者更好地理解非阻塞I/O
package test;
import
import java
import java
import java
public class FirstNonBlockingIO
{
public static void main(String[] args) throws Exception
{
SocketAddress remote = new InetSocketAddress(
SocketChannel channel = SocketChannel
String request =
ByteBuffer header = ByteBuffer
channel
ByteBuffer buffer = ByteBuffer
WritableByteChannel out = Channels
while (channel
{
buffer
out
buffer
}
channel
}
}
測試
執行如下命令
java test
打開sina
HTTP/
Date: Sun
Server: Apache/
Last
Connection: close
</body>
</html>
由於新浪網的主頁內容太多
除了上面的三點外
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26564.html