为什么OutputStream的write(int b)方法存在? [英] Why does the write(int b) method of OutputStream exist?

查看:128
本文介绍了为什么OutputStream的write(int b)方法存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

为什么Java OutputStream.write()采用整数但写入字节

为什么 OutputStream 类的 write()方法取整数当它实际上逐字节地写入数据时,而不是一个字节?

Why does the write() method of the OutputStream class take an integer instead of a byte when it actually writes data byte by byte?

推荐答案

它是一致的w / IntputStream .read()并且由于大多数操作(sum,mul,div等)都被提升为int,因此无需经常转换为 byte

it is consistent w/ IntputStream.read() and since most operations (sum, mul, div, etc) are promoted to int, it removes the need to constantly cast to byte.

我认为没关系。

这篇关于为什么OutputStream的write(int b)方法存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆