Abstract interface ObjectOutput in Java

digitization, transformation, binary

Abstract interface ObjectOutput in Java

ObjectOutput interface extends the DataOutput interface and adds methods for serializing objects and writing bytes and arrays of bytes.
DataOutput defines methods for reading primitive types from a stream, ObjectOutput defines methods for writing objects and arrays of bytes.


public abstract interface java.io.ObjectOutput extends java.io.DataOutput{
// Public Instance Methods
public abstract void close() throws IOException;
public abstract void flush() throws IOException;
public abstract void write(int b) throws IOException;// From DataOutput
public abstract void write(byte [ ] b) throws IOException;// From DataOutput
public abstract void write(byte [ ] b, int off, int len) throws IOException;// From DataOutput
public abstract void writeObject(Object obj) throws IOException;
}

The details of the methods are as follows:

Ads code goes here
public abstract void close() throws IOException;

public abstract void close() throws IOException method closes the stream and releases any system resources associated with it.

public abstract void flush() throws IOException;

public abstract void flush() throws IOException method forces any bytes that may be buffered by the output stream to be written to the underlying physical device in case If the stream uses a buffer.

public abstract void write(int b) throws IOException;// From DataOutput

public abstract void write(int b) throws IOException method writes the lowest eight bits of the given integer b to the stream.
Parameter
b-The value to write.

public abstract void write(byte [ ] b) throws IOException;// From DataOutput

public abstract void write(byte [ ] b) throws IOException method writes all of the 8-bit bytes in the given array to the stream.
Parameter
b-An array of bytes to write to the stream.

public abstract void write(byte [ ] b, int off, int len) throws IOException;// From DataOutput

public abstract void write(byte [ ] b, int off, int len) throws IOException method writes len bytes from the given array, starting off elements from the beginning of the array, to the stream.

READ  Variables in Java

Parameter
b-An array of bytes to write to the stream.
off-An offset into the byte array.
len-The number of bytes to write.

public abstract void writeObject(Object obj) throws IOException;

public abstract void writeObject(Object obj) throws IOException method writes the given object to the stream, or in other words, it serializes an object to the stream. The class that implements this interface determines how the object is written.

Apart from these methods ObjectOutput interface also has inherited methods from DataOutput. They are as follows:

  • writeBoolean(boolean)
  • writeBytes(String)
  • writeChars(String)
  • writeFloat(float)
  • writeLong(long)
  • writeUTF(String)
  • writeByte(int)
  • writeChar(int)
  • writeDouble(double)
  • writeInt(int)
  • writeShort(int)

Share and Enjoy !

13 thoughts on “Abstract interface ObjectOutput in Java”

  1. These are really great ideas in regarding blogging.
    You have touched some fastidious things here.
    Any way keep up wrinting.

  2. Hey there outstanding blog! Does running a blog
    similar to this require a lot of work? I’ve absolutely no understanding
    of computer programming but I was hoping to start my own blog in the near future.
    Anyways, if you have any ideas or techniques for new blog owners please share.
    I understand this is off topic however I simply needed to ask.
    Thank you!

  3. Hola! I’ve been following your web site for some time now and finally got
    the courage to go ahead and give you a shout out from
    Humble Texas! Just wanted to say keep up the fantastic work!

  4. Pingback: Google

  5. It’s really very difficult in this busy life to listen news on Television, so
    I just use web for that reason, and get the most recent
    news.

  6. Definitely consider that which you stated.
    Your favorite reason appeared to be on the internet the simplest thing to be aware of.
    I say to you, I certainly get annoyed at the same time as people think about worries that they just
    do not recognize about. You controlled to hit the nail upon the
    highest as well as outlined out the entire thing with no need side effect , other people could take a signal.
    Will likely be back to get more. Thank you

  7. I was excited to uncover this site. I want to to thank
    you for your time due to this wonderful read!! I definitely
    liked every little bit of it and I have you book marked
    to check out new stuff on your site.

  8. Pingback: Google

  9. Pingback: Google

  10. Pingback: Google

Leave a Comment

Your email address will not be published. Required fields are marked *