mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -18,7 +18,7 @@ public class AioServerTest {
|
||||
@Override
|
||||
public void accept(final AioSession session) {
|
||||
StaticLog.debug("【客户端】:{} 连接。", session.getRemoteAddress());
|
||||
session.write(BufferUtil.createUtf8("=== Welcome to Hutool socket server. ==="));
|
||||
session.write(BufferUtil.ofUtf8("=== Welcome to Hutool socket server. ==="));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,7 +32,7 @@ public class AioServerTest {
|
||||
.append("Content-Type: text/html; charset=UTF-8\r\n")//
|
||||
.append("\r\n")
|
||||
.append("Hello Hutool socket");//
|
||||
session.writeAndClose(BufferUtil.createUtf8(response));
|
||||
session.writeAndClose(BufferUtil.ofUtf8(response));
|
||||
}else {
|
||||
session.read();
|
||||
}
|
||||
|
@@ -34,8 +34,8 @@ public class NioClientTest {
|
||||
});
|
||||
|
||||
client.listen();
|
||||
client.write(BufferUtil.createUtf8("你好。\n"));
|
||||
client.write(BufferUtil.createUtf8("你好2。"));
|
||||
client.write(BufferUtil.ofUtf8("你好。\n"));
|
||||
client.write(BufferUtil.ofUtf8("你好2。"));
|
||||
|
||||
// 在控制台向服务器端发送数据
|
||||
Console.log("请输入发送的消息:");
|
||||
@@ -43,7 +43,7 @@ public class NioClientTest {
|
||||
while (scanner.hasNextLine()) {
|
||||
final String request = scanner.nextLine();
|
||||
if (request != null && request.trim().length() > 0) {
|
||||
client.write(BufferUtil.createUtf8(request));
|
||||
client.write(BufferUtil.ofUtf8(request));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -45,6 +45,6 @@ public class NioServerTest {
|
||||
public static void doWrite(final SocketChannel channel, String response) throws IOException {
|
||||
response = "收到消息:" + response;
|
||||
//将缓冲数据写入渠道,返回给客户端
|
||||
channel.write(BufferUtil.createUtf8(response));
|
||||
channel.write(BufferUtil.ofUtf8(response));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user