Results 1 to 3 of 3
- 06-10-2011, 04:58 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
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
- 06-10-2011, 05:04 AM #2
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]
- 06-10-2011, 05:34 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
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
-
Java program is not loading
By shoeb83 in forum New To JavaReplies: 2Last Post: 12-29-2009, 02:15 AM -
Problem loading in a .txt file
By blkshp1990 in forum New To JavaReplies: 1Last Post: 11-06-2009, 02:48 AM -
loading a text file
By nick2price in forum New To JavaReplies: 2Last Post: 12-24-2008, 12:46 AM -
Loading of JSP file failed
By Heather in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 08-06-2007, 01:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks