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

The Archive Base Latest Questions

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

Now I am creating an address book in Java 1.6. Now how I have

  • 0

Now I am creating an address book in Java 1.6. Now how I have it set up is when you add a contact it gets saved into an array. I have no problem writing the array, however when it comes to reading it I dont know how to get every object I previously saved, and load it into the array again.

Just do you know: addbook is my file, it is a txt file. Array is the array I am using to store the objects. The sort I am using is an insertion sort that sorts the contacts by name. If I have not covered other variable names, and stuff like that, I can clarify.

Finally, just for clarification, my question is asking how I can read the array I saved to a file.
Here is my read code:

try {
    FileInputStream in = new FileInputStream(addBook);
    ObjectInputStream readIn = new ObjectInputStream(in);

    array = readIn.readObject();
    readIn.close();


    Sorts.insertionSort(array);

    model.removeAllElements();

    for (int i = array.length - 1; i > 0; i--) {
        model.addElement(((Book) array[i]).getContact());
    }
    comboBox.setModel(model);

} catch (Exception e) {
     e.printStackTrace();
}
  • 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-05T21:30:08+00:00Added an answer on June 5, 2026 at 9:30 pm

    ObjectInputStream.readObject returns an Object. You cannot assign an Object to a Comparable[] without a cast: array = (Comparable[]) readIn.readObject().

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

Sidebar

Related Questions

I'm writing my first MVC app right now and am creating a new MembershipProvider
I'm writing my first MVC app right now and am creating a new MembershipProvider
I have a cakePhp application built, and now I'm creating a simple blog based
After creating the parse tree, i have to populate symbol table now. I have
I'm creating a form. As of right now I have simple MAILTO form that
I have varying mailto: email address on my site which are now being hit
I'm creating a web page that user can send pm , receive it,add contact,response
I am creating a basic app for an address book and would like to
Right now I am creating a UITableView in a FlipsideView nib. I don't seem
I am creating a windows application. I am now concentrating on the Reporting Module

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.