* Flushes the stream. This will write any buffered output bytes and flush
* through to the underlying stream.
*
* @throws IOException If an I/O error has occurred.
*/
// 刷新該流的緩衝、這裏也會將底層流中的數據flush到底層流指定的目的地中。
public void flush() throws IOException {
bout.flush();
}
void
write(
byte
[] buf); 寫入一個
byte
數組。
void
write(
byte
[] buf,
int
off,
int
len); 寫入字節的子數組。
void
write(
int
val); 寫入一個字節。
void
writeBoolean(
boolean
val); 寫入一個
boolean
值。
void
writeByte(
int
val); 寫入一個
8
位字節。
void
writeBytes(String str); 以字節序列形式寫入一個 String。
void
writeChar(
int
val); 寫入一個
16
位的
char
值。
void
writeChars(String str); 以
char
序列形式寫入一個 String。
void
writeDouble(
double
val); 寫入一個
64
位的
double
值。
void
writeFields(); 將已緩衝的字段寫入流中。
void
writeFloat(
float
val); 寫入一個
32
位的
float
值。
void
writeInt(
int
val); 寫入一個
32
位的
int
值。
void
writeLong(
long
val); 寫入一個
64
位的
long
值。
void
writeObject(Object obj); 將指定的對象寫入 ObjectOutputStream。
void
writeShort(
int
val); 寫入一個
16
位的
short
值。
void
writeUTF(String str); 以 UTF-
8
修改版格式寫入此 String 的基本數據。
ObjectOutputStream、ObjectInputStream這對流本質上就是操作序列化對象、用於在介質間進行傳遞序列化對象的屬性、當然、當我們想要保存對象的某個屬性的時候可以使用DataOutputStream、DataInputStream這對流、但是當我們要保存的屬性恰好組成了一個對象、並且這個對象還有版本、作者等信息時、DataOutputStream這對流就不能滿足我們了、其實如上面所說、ObjectInputStream這對流也是間接實現了DataOutputStream這對流的接口、並且中間穿插了一個ObjectOut這對接口、這對接口對DataOut這對進行了擴展、滿足傳輸對象、數組、字符串。