Posted By:
Luigi_Viggiano
Posted On:
Friday, October 5, 2001 02:40 PM
What a bad idea to think to Cobol writing Java ;) !
With Java your records are represented by object that are defined by classes. Object can be made persistent writing other classes that handle their persistence on the db.
example
/* Those are what you can compare to C structs:
*/
class Address {
String street;
String city;
String cap;
//get & set if you want...
}
class Customer {
String name;
int age;
Address address;
//get & set if you want...
}
class CustomerHandler {
Collection customers;
public void readCustomerFromFile(java.io.File file) {
//reads the file and populate the collection.
}
public void storeCustomersToDatabase() {
//...
}
public void storeCustomersToFile(java.io.File file) {
//...
}
}
For the class RecLayout, if you are making a real-world application, it's better to think about using a good database instead of thinking to implement your own. If you are playing with java, it could be an interresting exercise ;-) & good luck.