# Set root logger level to DEBUG and its only appender to A1.log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c{1} %x - %m%n
// Allocates a new buffer with a specific size, defining its type (direct or heap)publicstaticIoBufferallocate(intcapacity,booleandirect)// Allocates a new buffer with a specific sizepublicstaticIoBufferallocate(intcapacity)
创建自增的IoBuffer
在3.0版本中会被移除,使用InputStream或者固定大小buffer替代
1234567
IoBufferbuffer=IoBuffer.allocate(8);buffer.setAutoExpand(true);buffer.putString("12345678",encoder);// Add more to this bufferbuffer.put((byte)10);
自减空间的buffer
1234567891011
IoBufferbuffer=IoBuffer.allocate(16);buffer.setAutoShrink(true);buffer.put((byte)1);System.out.println("Initial Buffer capacity = "+buffer.capacity());buffer.shrink();System.out.println("Initial Buffer capacity after shrink = "+buffer.capacity());buffer.capacity(32);System.out.println("Buffer capacity after incrementing capacity to 32 = "+buffer.capacity());buffer.shrink();System.out.println("Buffer capacity after shrink= "+buffer.capacity());