随笔分类 - java其它
摘要:import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.*; import io.netty
阅读全文
摘要:<dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.1.68.Final</version> </dependency> import io.netty.bootstrap.Se
阅读全文
摘要:MessagePack Java 模块 GitHub 开源地址:https://github.com/msgpack/msgpack-java <dependency> <groupId>org.msgpack</groupId> <artifactId>msgpack</artifactId> <
阅读全文
摘要:无法跨语言 序列化后的码流太大 序列化性能太低 import java.io.Serializable; import java.nio.ByteBuffer; public class UserInfo implements Serializable { private String userNa
阅读全文
摘要:FixedLengthFrameDecoder 定长解码器的使用 import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io
阅读全文
摘要:DelimiterBasedFrameDecoder 分割符解码器的使用,将消息使用$$分割,解决TCP粘包问题 import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.bu
阅读全文
摘要:未考虑TCP粘包导致功能异常案例 import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.*
阅读全文
摘要:依赖版本 <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.1.68.Final</version> </dependency> 服务端 import io.netty.boo
阅读全文
摘要:如果类的构造器或者静态工厂中具有多个参数,设计这种类时, Builde模式就是一种不错的选择, 特别是当大多数参数都是可选或者类型相同的时候 。 与使用 重叠构造器模式相比,使用 Builder模式 的客户端代码将更 易于 阅读和编写,构建器也比 JavaBeans 更加安全 import java
阅读全文
摘要:```java import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class ListDemo { //jdk8 public static void main(String[] args){ // add("ArrayList",50000)...
阅读全文
摘要:```java public class CharAtStartWithDemo { public static void main(String[] args){ //jdk8 testCharAt();//1 testStartWith();//4 } public static void te
阅读全文
摘要:```java import java.util.StringTokenizer; public class SplitDemo { //jdk8 public static void main(String[] args){ String s = "a,b,c"; String[] split =
阅读全文
摘要:```java
public class SubStringDemo { //substring() /** * jdk6 当调用 substring() 方法时,创建了一个新的String对象,但是string的value[] 属性域仍然指向堆内存中的原来的那个数组。区别就是 两个对象的 count 和 offset 这两个值不同了 * //JDK6,包级私有...
阅读全文
摘要:```java public class Str { //测试环境jdk1.8 //参考:https://www.jianshu.com/p/d5ecfceccccd public static void main(String[] args){ char[] c = {'a','b','c'}; String s = new String(c); //生成2哥对象分别存放在堆空间,常量池 Str
阅读全文

浙公网安备 33010602011771号