1987WEB视界-分享互联网热门产品和行业

您现在的位置是:首页 > WEB开发 > 正文

WEB开发

后浪云鸿蒙OS教程:鸿蒙OS ObjectOutput

1987web2025-04-14WEB开发21
ObjectOutputpublicinterfaceObjectOutputextendsDataOutput,AutoCloseable

ObjectOutput

public interface ObjectOutput extends DataOutput, AutoCloseable

ObjectOutput 扩展了 DataOutput 接口以包括对象的写入。 DataOutput 包括用于输出原始类型的方法,ObjectOutput 扩展了该接口以包括对象、数组和字符串。

Since:

JDK1.1

方法总结

修饰符和类型方法描述voidclose()关闭流。voidflush()冲洗流。voidwrite(byte[] b)写入一个字节数组。voidwrite(byte[] b, int off, int len)写入一个子字节数组。voidwrite(int b)写入一个字节。voidwriteObject(Object obj)将对象写入底层存储或流。从接口 java.io.DataOutput 继承的方法writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF

方法详情

writeObject

void writeObject(Object obj) throws IOException

将对象写入底层存储或流。 实现此接口的类定义了对象的编写方式。

参数:

参数名称参数描述obj要写入的对象

Throws:

Throw名称Throw描述IOException任何常见的输入/输出相关异常。

write

void write(int b) throws IOException

写入一个字节。 此方法将阻塞,直到实际写入字节。

指定者:

写入接口DataOutput

参数:

参数名称参数描述b字节

Throws:

Throw名称Throw描述IOException如果发生 I/O 错误。

write

void write(byte[] b) throws IOException

写入一个字节数组。 此方法将阻塞,直到实际写入字节。

指定者:

写入接口DataOutput

参数:

参数名称参数描述b要写入的数据

Throws:

Throw名称Throw描述IOException如果发生 I/O 错误。

write

void write(byte[] b, int off, int len) throws IOException

写入一个子字节数组。

指定者:

写入接口DataOutput

参数:

参数名称参数描述b要写入的数据off数据中的起始偏移量len写入的字节数

Throws:

Throw名称Throw描述IOException如果发生 I/O 错误。

flush

void flush() throws IOException

冲洗流。 这将写入任何缓冲的输出字节。

Throws:

Throw名称Throw描述IOException如果发生 I/O 错误。

close

void close() throws IOException

关闭流。 必须调用此方法来释放与流关联的任何资源。

指定者:

在接口 AutoCloseable 中关闭

Throws:

Throw名称Throw描述IOException如果发生 I/O 错误。