In this chapter, we study ObjectInputStream and ObjectOutputStream
Introduction to ObjectInputStream and ObjectOutputStream
The role of ObjectInputStream and ObjectOutputStream is to support the serialization of basic data and objects.
Creates a ObjectOutputStream object that corresponds to the file output stream, which provides persistent storage for "basic data or objects" and creates a "file input stream" When we need to read "Basic data or objects" for these stores. Corresponding ObjectInputStream, which then reads out these "basic data or objects".
Note: Only objects that support java.io.Serializable or java.io.Externalizable interfaces can be manipulated by Objectinputstream/objectoutputstream!
ObjectOutputStream Function List
Constructor
ObjectOutputStream (outputstream Output)
//Public function
void close ()
void Defaultwriteobject ()
void flush ()
Objectoutputstream.putfield putfields ()
void Reset ()
void useprotocolversion (int version)
void write (int value)
void Write (byte [] buffer, int offset, int length)
void Writeboolean (boolean value)
void writebyte (int value)
void writebytes (string value)
void Writechar (int value)
void WriteChars (string Value)
void writedouble (double value)
void writefields ()
void writefloat (float Value)
void writeint (int value)
void Writelong (Long value)
final void writeobject ( object)
void writeshort (int value) void writeUTF (String value)
void Writeunshared (Object object)
ObjectInputStream Function List
Constructor
ObjectInputStream (InputStream input)
int available () void close ()
void Defaultreadobject ()
int read (byte[] buffer, int offset, int length)
int Read ()
Boolean Readboolean ()
byte readbyte ()
char Readchar ()
double readdouble
() Objectinputstream.getfield readfields ()
float readfloat ()
void readfully (byte[] DST)
void readfully (byte[] DST, int offset, int byteCount)
int readInt ()
String readLine (
long Readlong ()
final Object readobject () short readshort ()
String readUTF ()
Object readunshared ()
int readunsignedbyte ()
int readunsignedshort ()
synchronized void registervalidation (objectinputvalidation object, int priority)
int skipbytes (int length)
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/