Results 1 to 3 of 3
  1. #1
    crivers is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Loading an old file into an updated program

    Hi guys,

    I am relatively new to Java and am currently working on a simple rental property management program. I already have a working version of the program, but have since went on to make some updates unfortunately I can no longer open up files that were created in the old version of the program. I have since added some methods to a base class that is being saved off and that seems to be the issue, but I need to be able to do such things in order to better my program. Any suggestions on how to open the old files?

    Thanks in advance,
    crivers

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

    Default

    Let me see, we know zilch about your program, we know zilch about your saved file format, we know zilch about how you read/write the file, we know zilch period.

    Yeah I'm sure someone can help.
    [/sarcasm]

  3. #3
    crivers is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default

    Sorry like I said I'm new to this. To answer the question about the program I currently have a "Property" class that lays out the properties of a what a Property is (address, tenant, income, and various outgoing cash flow options). I also have a "Property Engine" class that is used to make changes to the properties and display the list of Properties in a JList. In the "Property Engine" class there is an ArrayList of Properties. When the user saves their information, this ArrayList (along with an ArrayList of Tenants using the same process) are saved off to a file. Since I first released this program I have made some changes to it that needed me to add methods to the "Property" class, but now when I try to read in a file from the old version it gives me an 'InvalidClassException'. My code for writing and reading is called from the following two methods:

    /************************************************** ****************
    * Saves database
    *
    * @param filename filename
    ************************************************** ***************/
    public void saveDatabase(String filename, JFrame frame) {
    try {
    FileOutputStream fos = new FileOutputStream(filename + ".pme");
    ObjectOutputStream os = new ObjectOutputStream(fos);
    os.writeObject(tenants);
    os.writeObject(properties);
    os.close();
    } catch (IOException ex) {
    JOptionPane.showMessageDialog(frame, "Invalid Filename. Try Again.");
    }
    }

    /************************************************** ****************
    * Loads database
    *
    * @param filename filename
    ************************************************** ***************/
    public void loadDatabase(String filename, JFrame frame) {
    try {
    FileInputStream fis = new FileInputStream(filename);
    ObjectInputStream is = new ObjectInputStream(fis);

    tenants = (ArrayList<Tenant>) is.readObject();
    properties = (ArrayList<Property>) is.readObject();

    tEngine.setTenantList(tenants);
    pEngine.setPropertyList(properties);

    pEngine.loadDatabase();
    tEngine.loadDatabase();

    is.close();
    }
    catch (Exception ex) {

    }
    }


    Hope this is more useful to work with. Thanks again!

Similar Threads

  1. Java program is not loading
    By shoeb83 in forum New To Java
    Replies: 2
    Last Post: 12-29-2009, 02:15 AM
  2. Problem loading in a .txt file
    By blkshp1990 in forum New To Java
    Replies: 1
    Last Post: 11-06-2009, 02:48 AM
  3. loading a text file
    By nick2price in forum New To Java
    Replies: 2
    Last Post: 12-24-2008, 12:46 AM
  4. Loading of JSP file failed
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-06-2007, 01:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •