Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
I/O and Streams
class invalid for deserialization
Bud Tippins
Ranch Hand
Posts: 52
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have the following code. Running in NetBeans. I'm receiving an error that "class invalid for deserialization"
What do I need to do here to prepare the class for deserialization?
Thank you.
package savebox; import java.io.*; public class SaveBox { private int width; private int height; public static void main(String[] args) { SaveBox myBox = new SaveBox(); myBox.go(); } public void go() { try { FileInputStream filestream = new FileInputStream("foo.ser"); ObjectInputStream os = new ObjectInputStream(filestream); Object one = os.readObject(); Object two = os.readObject(); width = (int) (Integer) one; height = (int) (Integer) two; os.close(); } catch(Exception ex) { ex.printStackTrace(); } System.out.println("width = " + width); System.out.println("height = " + height); } }
Rob Spoor
Sheriff
Posts: 22783
131
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Once
is enough, thank you.
UseOneThreadPerQuestion
.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to detect end of file
Serialization/Deserialization a picture
Serialization JSCP 6.0 (manually invoking writeObject() )
Deserializing an object using a class description which does not contain a field in the object.
read a file content of serialized object
More...