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 7888037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:44:03+00:00 2026-06-03T05:44:03+00:00

I creating a program that will calculate something and store the information into a

  • 0

I creating a program that will calculate something and store the information into a hashTable. What I want it to do is the next time it runs to restore the previous values stored in the hashTable and resume. So I ask how to save an object to a file?

In my code, I am using FileInputStream and FileOutputStream. Here is a snip-bit of my code, so far:

@SuppressWarnings("unchecked")
private void obtainSaveFile(){
    String file = new String("./saveFile.txt");
    try{
        //Create the file if it doesn't exist
        if( !( (new File(file)).exists() ) ){

            //Create new empty file
            (new File(file)).createNewFile();

            //Creates a fresh new hashTable
            hashTable = new QuadraticProbingHashTable<TicTacToeBoard>();
        }
        else{
            //Obtain the hashTables saved config.txt file
            FileInputStream fis = new FileInputStream(file);
            ObjectInputStream ois = new ObjectInputStream(fis);

            //Obtain the previously saved hashTable
            //-----------------------------------
            //This line of code gives me an error
            //-----------------------------------
            hashTable = (QuadraticProbingHashTable<TicTacToeBoard>)ois.readObject();
            ois.close();
        }

        //Create save file configs.txt
        FileOutputStream fos = new FileOutputStream(file);
        saveFile = new ObjectOutputStream(fos);     

    }catch(Exception e){
        e.printStackTrace();

        //Creates a fresh new hashTable
        //This line of code gives me an error
        hashTable = new QuadraticProbingHashTable<TicTacToeBoard>();
    }
}

Initially, when there is no file, it runs fine. But after that, it keeps giving me errors. It doesn’t like when I take an object from the file and cast it as a QuadraticProbingHashTable and set that equal to hashTable.

Also, here is what is outputed as the error:

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: proj4.QuadraticProbingHashTable$HashEntry
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readArray(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    at java.io.ObjectInputStream.readSerialData(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at proj4.TicTacToeSolver.obtainSaveFile(TicTacToeSolver.java:308)
    at proj4.TicTacToeSolver.solve(TicTacToeSolver.java:120)
    at proj4.Main.main(Main.java:41)
Caused by: java.io.NotSerializableException: proj4.QuadraticProbingHashTable$HashEntry
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.writeArray(Unknown Source)
    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)
    at proj4.TicTacToeSolver.solve(TicTacToeSolver.java:246)
    ... 1 more
Exception in thread "main" java.lang.NullPointerException
    at proj4.TicTacToeSolver.solve(TicTacToeSolver.java:246)
    at proj4.Main.main(Main.java:41)
  • 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-03T05:44:05+00:00Added an answer on June 3, 2026 at 5:44 am

    Well, the problem seems to be, that you are trying to serialize something which does not implement Serializable.
    You can see that here:

    java.io.NotSerializableException: proj4.QuadraticProbingHashTable$HashEntry
    

    You have two choices:

    1. You let HashEntry implement Serializable if thats possible
    2. You mark it as transient so it will not be serialized (probably not what you want).

    For more details you could post the class.

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

Sidebar

Related Questions

I'm creating a program that authenticates from a before it runs. I also want
I'm creating a Win32 program that will be executed every time the computer turns
I am creating a program that will fill in a given grammar. Right now
OK, let's say I am creating a program that will list users contacts in
I am creating a program that will print out digits of pi up to
I'm planning on creating a program that will have a login form and then
I am trying to improve my C++ by creating a program that will take
I am creating an Objective-C program that when calling a C function, it will
I have been tasked with creating a program that will generate an amortization schedule.
I am creating a program that will run an experiment on a user. It

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.