java.lang.Object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.OutputStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.ObjectOutputStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
An ObjectOutputStream writes primitive data types and Java objects to an OutputStream.
Constructor | Summary |
---|---|
ObjectOutputStream(OutputStream out) | Creates an ObjectOutputStream that writes to the specified OutputStream. |
Return | Method | Summary |
---|---|---|
void | close() | Closes the stream. |
void | defaultWriteObject() | Write the non-static and non-transient fields of the current class to this stream. |
void | flush() | Flushes the stream. |
void | reset() | Reset will disregard the state of any objects already written to the stream. |
void | useProtocolVersion(int version) | Specify stream protocol version to use when writing the stream. |
void | write(byte[] buf) | Writes an array of bytes. |
void | write(byte[] buf, int off, int len) | Writes a sub array of bytes. |
void | write(int val) | Writes a byte. |
void | writeBoolean(boolean val) | Writes a boolean. |
void | writeByte(int val) | Writes an 8 bit byte. |
void | writeBytes(String str) | Writes a String as a sequence of bytes. |
void | writeChar(int val) | Writes a 16 bit char. |
void | writeChars(String str) | Writes a String as a sequence of chars. |
void | writeDouble(double val) | Writes a 64 bit double. |
void | writeFields() | Write the buffered fields to the stream. |
void | writeFloat(float val) | Writes a 32 bit float. |
void | writeInt(int val) | Writes a 32 bit int. |
void | writeLong(long val) | Writes a 64 bit long. |
void | writeObject(Object obj) | Write the specified object to the ObjectOutputStream. |
void | writeShort(int val) | Writes a 16 bit short. |
void | writeUnshared(Object obj) | Writes an "unshared" object to the ObjectOutputStream. |
void | writeUTF(String str) | Primitive data write of this String in modified UTF-8 format. |
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Date;
public class Main {
public static void main(String args[]) throws IOException {
FileOutputStream fos = new FileOutputStream("t.tmp");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeInt(12345);
oos.writeObject("Today");
oos.writeObject(new Date());
oos.close();
}
}
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |