[Java]How to correct the overflowing variables generated from the situation we capture the single byte of data from files?

左心房为你撑大大i 提交于 2019-12-11 09:20:03

问题


As tilte,

I tried to capture the file size info which is saved in 4 bytes of data from bitmap's file code,

but if I use byte[] to save it and any byte of file exceeds 127, it'd be misjudged as negative values,

in this case how could we correct these kind of values?

My book just simply plus 256 to it, but could it fixedly be -128?

if not, then the result still isn't correct.

I know we can just use int[] or larger array for it, just wanna know how to deal with these kind of problems!

Thanks a lot for helping!!!

来源:https://stackoverflow.com/questions/31366865/javahow-to-correct-the-overflowing-variables-generated-from-the-situation-we-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!