Learn Java Tutorial for Beginners, Part 47: Serializing Multiple Objects

Java

Video is ready, Click Here to View ×


Get complete courses at http://courses.caveofprogramming.com
Building on the last tutorial, in this tutorial we’ll take a look at how to serialize entire arrays or array lists, either all at once or object by object.

30 thoughts on “Learn Java Tutorial for Beginners, Part 47: Serializing Multiple Objects

  1. Hi Cave of Programming. Thanks for your wonderful tutorial videos. In this video, you showed how to write initialized objects (i.e. programmer-defined values). But what to do if the user enters the values idNum and name? Could you please show us how to do it. I tried it but everytime I run the code, it give me "StreamCorruptedException: invalid type code: AC" error message. I hope you would find time to answer this humble query of mine. More power and Thanks again.

  2. hey is there any reason not to do this — try (ObjectInputStream os = new ObjectInputStream(new FileInputStream("test.ser"))) — instead of creating a variable fs to hold the FileInputStream?

  3. Hello john i have been watching your videos its great thanks! but i got an error null pointer exception in code (Arrays.asList(people)); in class write objects , please help me i have been trying to figure out for almost 5 hours how to fix this thanks .

  4. Hello there,
    Actually I'm making an application where it inserts an object of contacts in a file, and it goes by very fine.
    But when I attempt to read more than one object from the file using a while loop I get that exception and I have no idea why.
    The exception is this:
    java.io.StreamCorruptedException: invalid type code: AC
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)

    And when I searched about that exception I found out that the problem is that one might open more than one ObjectOutputStream, while I'm not doing that. Or if they append in the ObjectOutputStream and I'm not doing that either.

    So any idea why that exception pops out? and how can I overcome it and be able to read from a file the number of objects that I want?

  5. Congrats to everyone who made it this far. It was quite the journey haha. I watched all of the videos at least once, most of them twice. Thanks for all the help John!

  6. Thanks for covering the why and not just the how like other videos do. You've no idea the difference it makes.

    The only issue I have is the code can be hard to read at times. I have been learning java any chance I get on my tablet going to work or on lunch beak. I watch other tutorials then because their text is bigger/zoomed in slightly, I usually have to wait and watch your videos at home on the big screen. Any chance of fixing that? Otherwise no big deal.

Leave a Reply

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