版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sharon_1987/article/details/53643929
public class Test {
public static void main(String[] args) {
try {
ServerSocketChannel serverChannel = ServerSocketChannel.open();
serverChannel.socket().bind(new InetSocketAddress(8888));
ByteBuffer buf = ByteBuffer.allocateDirect(1024);
SocketChannel client = serverChannel.accept();
while(true) {
buf.put("get / /n/n".getBytes());
buf.flip();
client.write(buf);
buf.clear();
client.close();
}
} catch (Exception e){
//logger.error("fail to create port 8888", e);
e.printStackTrace();
}
String test = "a###b######c";
String [] tt = org.apache.commons.lang3.StringUtils.splitByWholeSeparatorPreserveAllTokens(test, "###");
System.out.println(tt.length);
for (int i = 0; i< tt.length; i++){
System.out.println(tt[i]);
}
}
}