Java IO Learning (iv) ObjectInputStream and ObjectOutputStream

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.