Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › ObjectOutputStream.html
ObjectOutputStream (Java SE 11 & JDK 11 )
October 20, 2025 - An ObjectOutputStream writes primitive data types and graphs of Java objects to an OutputStream. The objects can be read (reconstituted) using an ObjectInputStream. Persistent storage of objects can be accomplished by using a file for the stream.
GitHub
github.com › AdoptOpenJDK › openjdk-jdk11 › blob › master › src › java.base › share › classes › java › io › ObjectOutputStream.java
openjdk-jdk11/src/java.base/share/classes/java/io/ObjectOutputStream.java at master · AdoptOpenJDK/openjdk-jdk11
March 2, 2019 - import static java.io.ObjectStreamClass.processQueue; import sun.reflect.misc.ReflectUtil; · /** * An ObjectOutputStream writes primitive data types and graphs of Java objects · * to an OutputStream.
Author AdoptOpenJDK
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › › java.base › java › io › ObjectOutput.html
ObjectOutput (Java SE 11 & JDK 11 )
January 20, 2026 - Package java.io · All Superinterfaces: AutoCloseable, DataOutput · All Known Implementing Classes: ObjectOutputStream · public interface ObjectOutput extends DataOutput, AutoCloseable · ObjectOutput extends the DataOutput interface to include writing of objects.
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › class-use › ObjectOutputStream.html
Uses of Class java.io.ObjectOutputStream (Java SE 11 & JDK 11 )
January 20, 2026 - Report a bug or suggest an enhancement For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › ObjectInputStream.html
ObjectInputStream (Java SE 11 & JDK 11 )
January 20, 2026 - Creates an ObjectInputStream that reads from the specified InputStream. A serialization stream header is read from the stream and verified. This constructor will block until the corresponding ObjectOutputStream has written and flushed the header.
GitHub
github.com › openjdk › jdk › blob › master › src › java.base › share › classes › java › io › ObjectOutputStream.java
jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java at master · openjdk/jdk
* <cite>Java Object Serialization Specification,</cite> Section 2, "Object Output Classes"</a> * @since 1.1 · */ public class ObjectOutputStream · extends OutputStream implements ObjectOutput, ObjectStreamConstants · { private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); ·
Author openjdk
Android Developers
developer.android.com › api reference › objectoutputstream
ObjectOutputStream | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
Litux
litux.nl › Books › Books › www.leothreads.com › e-book › oreillybookself › java › fclass › ch11_42.htm
[Chapter 11] ObjectOutputStream
The ObjectOutputStream class can write both primitive types and object instances to an underlying OutputStream. The objects and other data can then be read by an ObjectInputStream. These two classes provide persistent storage of objects when they are used in conjunction with FileInputStream ...
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › ObjectOutputStream.PutField.html
ObjectOutputStream.PutField (Java SE 11 & JDK 11 )
July 15, 2025 - java.io.ObjectOutputStream.PutField · Enclosing class: ObjectOutputStream · public abstract static class ObjectOutputStream.PutField extends Object · Provide programmatic access to the persistent fields to be written to ObjectOutput. Since: 1.2 · clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait ·
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › OutputStream.html
OutputStream (Java SE 11 & JDK 11 )
January 20, 2026 - java.io.OutputStream · All Implemented Interfaces: Closeable, Flushable, AutoCloseable · Direct Known Subclasses: ByteArrayOutputStream, FileOutputStream, FilterOutputStream, ObjectOutputStream, PipedOutputStream · public abstract class OutputStream extends Object implements Closeable, Flushable ...
o7planning
o7planning.org › 13399 › java-objectoutputstream
Java ObjectOutputStream Tutorial with Examples | o7planning.org
March 20, 2021 - Suppose you have a GameSetting object and you want to write it to ObjectOutputStream, but not all of its fields. ... package org.o7planning.beans; import java.io.IOException; import java.io.ObjectOutputStream; public class GameSetting implements java.io.Serializable { private static final long serialVersionUID = 1L; private int sound; private int bightness; private String difficultyLevel; private String userNote; public GameSetting(int sound, int bightness, String difficultyLevel, String userNote) { this.sound = sound; this.bightness = bightness; this.difficultyLevel = difficultyLevel; this.userNote = userNote; } public int getSound() { return sound; } public int getBightness() { return bightness; } public String getDifficultyLevel() { return difficultyLevel; } public String getUserNote() { return userNote; } // Do not change name and parameter of this method.
Scientech Easy
scientecheasy.com › home › blog › objectoutputstream in java
ObjectOutputStream in Java - Scientech Easy
February 11, 2025 - In other words, an ObjectOutputStream is an output stream that serializes primitive type values, strings, and objects to a stream. Since Java ObjectOutputStream contains all the methods of DataOutputStream, we can perform output operations for objects in addition to primitive type values and ...
CodeJava
codejava.net › java-se › file-io › java-io-objectinputstream-and-objectoutputstream-examples
Java IO ObjectInputStream and ObjectOutputStream Examples
July 28, 2019 - This method throws IOException ... extends from the DataOutput interface, which means an ObjectOutputStream inherits all behaviors of writing primitive types and Strings like a DataOutputStream.Likewise, the ObjectInputStream class implements the ObjectInput interface that ...
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › ObjectInput.html
ObjectInput (Java SE 11 & JDK 11 )
January 20, 2026 - Package java.io · All Superinterfaces: AutoCloseable, DataInput · All Known Implementing Classes: ObjectInputStream · public interface ObjectInput extends DataInput, AutoCloseable · ObjectInput extends the DataInput interface to include the reading of objects.
GitHub
github.com › AdoptOpenJDK › openjdk-jdk11 › blob › master › src › java.base › share › classes › java › io › OutputStream.java
openjdk-jdk11/src/java.base/share/classes/java/io/OutputStream.java at master · AdoptOpenJDK/openjdk-jdk11
March 2, 2019 - * @since 11 · */ public static OutputStream nullOutputStream() { return new OutputStream() { private volatile boolean closed; · private void ensureOpen() throws IOException { if (closed) { throw new IOException("Stream closed"); } } ·
Author AdoptOpenJDK
Programiz
programiz.com › java-programming › objectoutputstream
Java ObjectOutputStream (With Examples)
Basically, the ObjectOutputStream encodes Java objects using the class name and object values. And, hence generates corresponding streams.
Classpath
developer.classpath.org › doc › java › io › ObjectOutputStream-source.html
Source for java.io.ObjectOutputStream (GNU Classpath 0.95 Documentation)
1: /* ObjectOutputStream.java -- Class used to write serialized objects 2: Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 3: Free Software Foundation, Inc. 4: 5: This file is part of GNU Classpath.
MIT
web.mit.edu › java_v1.1.6 › distrib › sgi_62 › webdocs › api › java.io.ObjectOutputStream.html
Class java.io.ObjectOutputStream
implements ObjectOutput, ObjectStreamConstants An ObjectOutputStream writes primitive data types and graphs of Java objects to an OutputStream. The objects can be read (reconstituted) using an ObjectInputStream. Persistent storage of objects can be accomplished by using a file for the stream.
Top answer 1 of 2
2
Apart from new key word, you forgot to implement Serializable
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class Test implements Serializable{
private int a = 10;
private double b = 7.5;
private String m = "valu";
public static void main(String[] args) throws IOException {
Test t = new Test();
ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("Test.dat"));
output.writeObject(t);
output.close();
}
}
2 of 2
1
Try
ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("Test.dat"));
You had missed the "new" so the compiler is looking for a static method rather than the constructor