本文整理匯總了Java中org.apache.mina.filter.codec.CumulativeProtocolDecoder類的典型用法代碼示例。如果您正苦於以下問題:Java CumulativeProtocolDecoder類的具體用法?Java CumulativeProtocolDecoder怎麽用?Java CumulativeProtocolDecoder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CumulativeProtocolDecoder類屬於org.apache.mina.filter.codec包,在下文中一共展示了CumulativeProtocolDecoder類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDecoder
import org.apache.mina.filter.codec.CumulativeProtocolDecoder; //導入依賴的package包/類
@Override
public ProtocolDecoder getDecoder(IoSession is) throws Exception {
return new CumulativeProtocolDecoder() {
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
if (in.remaining() > 0) {
byte[] buf = new byte[in.remaining()];
in.get(buf);
out.write(new String(buf, "US-ASCII"));
return true;
} else {
return false;
}
}
};
}
示例2: getDecoder
import org.apache.mina.filter.codec.CumulativeProtocolDecoder; //導入依賴的package包/類
public ProtocolDecoder getDecoder() throws Exception {
return new CumulativeProtocolDecoder() {
protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
if (in.remaining() > 0) {
byte[] buf = new byte[in.remaining()];
in.get(buf);
out.write(new String(buf, "US-ASCII"));
return true;
} else {
return false;
}
}
};
}