java中用到的几个write和read函数参数

本文详细介绍了 Java 中 BufferOutputStream 的 write 方法如何将指定缓冲区中的数据写入输出流,以及 InputStream 和 RandomAccessFile 类如何进行读写操作。这些方法在文件处理和数据流操作中极为常见。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


BufferOutoutStream:

BufferOutoutStream.write(byte[] buffer, int offset, int length):


bufferthe buffer to be written.
offsetthe start position in buffer from where to get bytes.
lengththe number of bytes from buffer to write to this stream.


InputStream:

InputStream.read(byte[] buffer, int byteOffset, int byteCount)


从Inputstream流中读取byteCount个字节保存到以byteOffset开头(指针位置)的buffer中。




RandomAccessFile:


read(byte[] buffer , int byteOffset , int byteCount)

从流中的当前位置(指针)读取byteCount个字节保存在以byteOffset位置(指针位置)开始的buffer中。返回实际读到的字节数,如果读到流的结尾返回-1


write(byte[] buffer, int byteOffset, int byteCount)

bufferthe buffer to write.
byteOffsetthe index of the first byte in buffer to write.
byteCountthe number of bytes from the buffer to write.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值