![]() TEA APIs |
In this section we'll see how to realize a simple method to perform Persistent Properties support. The code exposed is taken from the Source Codes of the TETRACTYS Enhanced Apis and is extensively used by the TEA Editor.
Two are the classes:
This class that can create objects that manage a Properties File. It's passed as an argument to the PropertiesOwners that share the same Properties File.
This is a class that holds Properties and refers to a main PropertiesManager.
PropertiesManager loads and saves Properties from a file.
public void load(String fileName) { file = fileName; try { FileInputStream f = new FileInputStream(file); properties.load(f); f.close(); } catch(IOException exc) { properties.clear(); } } public void save() { try { FileOutputStream f = new FileOutputStream(file); properties.save(f,null); f.close(); } catch(IOException exc) { } }
PropertiesOwner is associated to a PropertiesManager through the setPropertiesManager() method and has some methods to read Properties properly (e.g, getInteger()).
public void setPropertiesManager(PropertiesManager pm) { propertiesManager = pm; properties = pm.getProperties(); } public int getInteger(String prop) { return Integer.parseInt(properties.getProperty(prop)); }
You can find the complete source code in the TEA APIs page. Write directly to TETRACTYS Freeware for any question or suggestion.
![]() |
In the next Issue Java Tutorials will be | ![]() |
---|