Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:07:09+00:00 2026-06-05T20:07:09+00:00

I am looking for a way to output an instantiated class, an Object to

  • 0

I am looking for a way to output an instantiated class, an Object to a file. I have tried using FileStream and it doesn’t seem to be working. After researching, it seems as though i need to use a technique called “serialization”. I’m absolutely lost on this topic. Would someone please debug this code for me? I have a hunch that the problem is occurring because I am trying to serialize an abstract class within a normal class. The abstract class is java.util.Calendar.

class CalendarL implements java.io.Serializable{
    private static final long serialVersionUID = 1L;

    java.util.Calendar calendar;

    CalendarL (int date, int month, int year){
        calendar.set (Calendar.DATE, date);
calendar.set (Calendar.MONTH, month);
calendar.set (Calendar.YEAR, year);
    }
}

class IO {
    protected CalendarL reader() throws IOException, ClassNotFoundException{
        FileInputStream data = new FileInputStream("data.dat");
        ObjectInputStream dataObject = new ObjectInputStream(data);

        CalendarL calendar = (CalendarL)dataObject.readObject();

        dataObject.close();
        data.close();

        return calendar;
    }


    protected void output(CalendarL calendar) throws IOException, WriteAbortedException, NotSerializableException {
        new FileOutputStream("data.dat").close();

        FileOutputStream data = new FileOutputStream("data.dat");
        ObjectOutputStream dataObject = new ObjectOutputStream(data);

        dataObject.writeObject(calendar);
        dataObject.close();
        data.close();
   }

}

This is the error I get:

Exception in thread "main" java.io.NotSerializableException: hotelres.ClientL
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:07:11+00:00Added an answer on June 5, 2026 at 8:07 pm

    I have a hunch that the problem is occurring because I am trying to serialize an abstract class within a normal class. The abstract class is java.util.Calendar.

    That hunch is not correct. You serialize instances (not classes) and the class of an instance cannot be an abstract class. Besides, the Calendar class does implement Serializable … the javadoc says so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a way to have output in the same manner as
I'm looking for a way to output a VERY simple pdf file from Python.
I am currently looking for a way to output the test result nicely after
I'm looking for an easy way of printing output to a pdf file for
I am looking for a easy way to output milliseconds into hours-minutes-seconds. I have
I'm looking for a way to convert HTML to text. I tried using sanatize
I'm looking for a way to send the output of an arbitrary Emacs command
I am looking for a good, standard way to generate output in my RCP
I am using codeigniter and looking a way to enable directly editting of doc
I have been having some trouble finding a good way to output just the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.