ObjectInput 對象輸入,繼承DataInput,AutoCloseable
public Object readObject()
throws ClassNotFoundException, IOException;
public int read() throws IOException;
public int read(byte b[]) throws IOException;
public int read(byte b[], int off, int len) throws IOException;
public long skip(long n) throws IOException;
public int available() throws IOException;
public void close() throws IOException;
提供了7個接口,一個輸入對象,3個讀方法,一個跳過,一個長度,一個關閉方法(輸入輸出流都會有關閉方法)
ObjectOutput 對象輸出,繼承DataOutput,AutoCloseable
public void writeObject(Object obj)
throws IOException;
public void write(int b) throws IOException;
public void write(byte b[]) throws IOException;
public void write(byte b[], int off, int len) throws IOException;
public void flush() throws IOException;
public void close() throws IOException;
提供了6個接口,一個輸出對象,3個寫方法,一個刷新方法,一個關閉方法
flush()方法的作用是將緩存區的內容寫到文件中(java中數據不會直接寫入,而是放到緩存區,達到條件後寫入。當需要強制寫入的時候調用flush()方法);