🌐
GeeksforGeeks
geeksforgeeks.org › java › difference-between-objectinputstream-and-objectoutputstream-in-java
Difference Between ObjectInputStream and ObjectOutputStream in Java - GeeksforGeeks
July 23, 2025 - Implementation: Let us see the ObjectOutputStream with an is illustrated for which we create a POJO class called “VehicleSpecifications”. Note: It should implement Serializable, otherwise, java.io.NotSerializableException will be thrown.
🌐
Coding Shuttle
codingshuttle.com › home › handbooks › java programming handbook › objectinputstream and objectoutputstream
ObjectInputStream and ObjectOutputStream | Coding Shuttle
April 9, 2025 - ObjectOutputStream: Used to serialize Java objects into a stream of bytes and write them to an OutputStream (like a file). ObjectInputStream: Used to deserialize the stream of bytes into a Java object from an InputStream.
Discussions

Using ObjectOutputStream and ObjectInputStream in java, displaying the data in the file line by line on the screen - Stack Overflow
First of all i'm a beginner.(Please Excuse my mistakes) I'm trying to make a student information system. The 'Student' class inherits from the 'Person' class. In the methods inside the " More on stackoverflow.com
🌐 stackoverflow.com
[Java] Help Loading Objects Using ObjectInputStream
can you copy/paste your Database and Album classes? More on reddit.com
🌐 r/learnprogramming
4
1
July 23, 2016
StreamCorruptedException with ObjectInputStream iteration

I think the basic problem is that you're appending the existing file, which doesn't work well ObjectOutputStream, since it appends a header at the start of its stream. Then when you read the file, your code expects only a single ObjectStream, but it is actually multiple streams appended together.

I think the simplest solution, if possible, would be to have your writeToScoreList() method accept a list/array/etc of all the players, which could then be written with a single ObjectOutputStream, without having to append the existing file.

Another possible solution is described in this StackOverflow question. You can create a subclass of ObjectOutputStream that overrides the writeStreamHandler() so that it only calls reset(), and doesn't actually write anything. Then, if your file exists (resulting in your appending the file) you can use your subclass as the ObjectOutputStream; otherwise you can use the normal ObjectOutputStream class.

Another possible solution might be to change your writeFromScoreList() method so that it creates a new ObjectInputStream for each object that you read (since you're similarly creating an ObjectOutputStream for each object that you write).

More on reddit.com
🌐 r/javahelp
7
1
March 2, 2019
I am trying to read the serialized code and use it, however i am getting an error. Can anyone help me?
Actually to be even clearer, When put in Netbeans it doesnt catch an error, but when i run it and it gets to this point of the code it gets an error saying: Exception in thread "main" java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2598) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1318) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370) at finalproject.FinalProject.main More on reddit.com
🌐 r/javahelp
7
2
December 11, 2014
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › ObjectInputStream.html
ObjectInputStream (Java Platform SE 8 )
April 21, 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.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › ObjectOutputStream-example-Learn-Java-object-serialization
ObjectOutputStream example: A Java object serialization tutorial
In this Java serialization example, we will use both the ObjectOutputStream and the ObjectInputStream to save and retrieve the state of a simple JavaBean.
🌐
CodeJava
codejava.net › java-se › file-io › java-io-objectinputstream-and-objectoutputstream-examples
Java IO ObjectInputStream and ObjectOutputStream Examples
July 28, 2019 - The following StudentRecordWriter program uses the ObjectOutputStream class to write a list of Students object to a file on disk: import java.util.*; import java.text.*; import java.io.*; /** * StudentRecordWriter.java * This program illustrates how to use the ObjectOutputStream class for writing ...
🌐
Programiz
programiz.com › java-programming › objectinputstream
Java ObjectInputStream (With Examples)
Note: The Dog class implements the Serializable interface. It is because the ObjectOutputStream only writes the serializable objects to the output stream. To learn more, visit Java ObjectInputStream (official Java documentation).
🌐
Programiz
programiz.com › java-programming › objectoutputstream
Java ObjectOutputStream (With Examples)
Let's see how we can use ObjectOutputStream to store objects in a file and ObjectInputStream to read those objects from the files · import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; class Main { public static ...
🌐
Codespindle
codespindle.com › Java › Java_objectinputstream_Objectoutputstream.html
ObjectInputStream and ObjectOutputStream in Java
If you set this parameter to true, ObjectOutputStream will append data to the end of the file instead of overwriting it. package javaprogrammingdemo; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Scanner; public class javalabclass{ public static void main(String args[]) { try { employee e; System.out.println("Enter the Employee Details"); Scanner input = new Scanner(System.in); String name,empid,address,phone; ObjectOutputStream objout = new ObjectOutputStream(n
Find elsewhere
🌐
TechVidvan
techvidvan.com › tutorials › java-objectstream-class
Java ObjectStream Class with Examples - TechVidvan
December 2, 2024 - ObjectOutputStream named output using the FileOutputStream named file ObjectInputStream named input using the FileInputStream named fileStream ... We then used the object output stream to write the object to the file.
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java › io › objectinputstream
Java ObjectInputStream and ObjectOutputStream Example - Java Code Geeks
October 6, 2014 - package com.javacodegeeks.example; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; /** * * @author anirudh */ public class JavaObjectInputOutputStreamExample { public static void main(String[] args) { try { // Store Serialized User Object in File FileOutputStream fileOutputStream = new FileOutputStream( "/Users/anirudh/user.txt"); User user = new User("Anirudh", "lastName", "email"); ObjectOutputStream output = new ObjectOutputStream(fileOutputStream); output.writeObject(user); output.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › io › ObjectInputStream.html
ObjectInputStream (Java Platform SE 7 )
This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor. The subclass is expected to provide an override method with the modifier "final". ... ClassNotFoundException - Class definition of a serialized object cannot be found. OptionalDataException - Primitive data was found in the stream instead of objects. IOException - if I/O errors occurred while reading from the underlying stream ... Reads an "unshared" object from the ObjectInputStream.
🌐
YouTube
youtube.com › watch
ObjectInputStream and ObjectOutputStream class in Java - CSE1007 - Java Programming - YouTube
Code can be downloaded fromhttps://codespindle.com/Java/Java_objectinputstream_Objectoutputstream.htmlIn this lecture we will be looking at how to serialize ...
Published   September 7, 2020
🌐
YouTube
youtube.com › watch
ObjectOutputStream, ObjectInputStream demonstrated in Java - YouTube
A demonstration and simple example of saving Java objects natively to a file on disk, by using ObjectOutputStream/FileOutputStream and ObjectInputStream/File...
Published   May 14, 2023
🌐
Scientech Easy
scientecheasy.com › home › blog › objectinputstream in java
ObjectInputStream in Java - Scientech Easy
February 11, 2025 - Let’s take an example program where we will write student name, roll no, marks, percentage, and the current data to a file named objfile.txt and then will read these data using ObjectOutputStream and ObjectInputStream classes respectively. ... package javaProgram; import java.io.FileInputStream; ...
🌐
Javatpoint
javatpoint.com › java-objectinputstream
Java ObjectInputStream - Javatpoint
Java ObjectInputStream defaultReadObject() readBoolean() readField() readFully() read() readByte() readChar() readDouble() readFloat() readInt() readLine() readLong() readShort() readObject() readObjectOverride() readUnshared() readUnsignedShort() readUnsingedByte() readUTF() registerValidation() skipBytes() available() close() enableResolveObject() readStreamHeader()
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › io › objectstreams.html
Object Streams (The Java™ Tutorials > Essential Java Classes > Basic I/O)
The object stream classes are ObjectInputStream and ObjectOutputStream. These classes implement ObjectInput and ObjectOutput, which are subinterfaces of DataInput and DataOutput. That means that all the primitive data I/O methods covered in Data Streams are also implemented in object streams.
🌐
Jenkov
jenkov.com › tutorials › java-io › objectoutputstream.html
Java IO: ObjectOutputStream
September 3, 2015 - This example first creates an ObjectOutputStream connected to a FileOutputStream. Then it creates a Person object and writes it to the ObjectOutputStream, and then closes the ObjectOutputStream.
🌐
Stack Overflow
stackoverflow.com › questions › 72163777 › using-objectoutputstream-and-objectinputstream-in-java-displaying-the-data-in-t
Using ObjectOutputStream and ObjectInputStream in java, displaying the data in the file line by line on the screen - Stack Overflow
java.io.EOFException at java.base/java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:3159) at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1640) at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:495) at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:453) at Student.StudentServices.list(StudentServices.java:19) at Main.MainTest.menu(MainTest.java:47) at Main.MainTest.main(MainTest.java:14)*
🌐
Bureau of Economic Geology
beg.utexas.edu › lmod › agi.servlet › doc › detail › java › io › ObjectInputStream.html
java.io Class ObjectInputStream
For example to read from a stream ... FileInputStream istream = new FileInputStream("t.tmp"); ObjectInputStream p = new ObjectInputStream(istream); int i = p.readInt(); String today = (String)p.readObject(); Date date = (Date)p.readObject(); istream.close(); Classes control ...
🌐
Jenkov
jenkov.com › tutorials › java-io › objectinputstream.html
Java IO: ObjectInputStream
September 3, 2015 - This example first creates an ObjectOutputStream connected to a FileOutputStream. Then it creates a Person object and writes it to the ObjectOutputStream, and then closes the ObjectOutputStream.