java: PushbackInputStream

java.io.PushbackInputStream

0. 数据结构

protected byte[] buf;   // pushback buffer

protected int pos;

 

 

读取方向很重要,设计挺巧妙的

 

1. read

读取时,如果pushback buffer中有,则优先从buffer中读取,否则,从InputStream中读取;

2. unread(int b)     pushback操作

--pos,即从pushback buffer中申请1个字节的空间,放入回退的字节b

 3. unread(byte[] b, int off, int len)

pos -= len,即从pushback buffer中申请len个字节的空间,放入回退的字节数组b

unread单个字节好理解;unread多个字节,对照数据结构,应该好点

 4. 应用

org.springframework: spring-webmvc: 5.2.7.RELEASE中

AbstractMessageConverterMethodArgumentResolver中的内部类EmptyBodyCheckingHttpInputMessage,有用到该功能

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.sitech.prom.channelsettle.rehearsal.busi.compute.vo.ListResponseVo` out of START_ARRAY token at [Source: (PushbackInputStream); line: 1, column: 1] at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1464) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1238) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1190) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeFromArray(BeanDeserializer.java:604) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:190) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4482) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3487) ~[jackson-databind-2.11.0.jar:2.11.0] at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:239) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE] ... 21 common frames omitted
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值