I need something like java.util.Properties class, where the store() method writes 2 extra lines at the beginning of the file and the load() method reads this two lines and makes something with them. Should I extend the Properties class and override the load() and store() methods? how would then the code in this methods look like aproximately?(Is it possible at all to find the code for the classes of API?) Or is it better to create a new class with a HashTable() object and use the java.io.* package? Thank you for any help!
you could extend the Properties class, and over ride the store and load methods...you can use the "super()" to automatically duplicate what the superClass method is doing...so you can over ride the method. add your lines to the output stream and then call super().
I dont think you need the source code, but it is freely available the the JDK download I think.
You might find it cleaner to create a new class that has an instance of Properties. Your methods might look like:
This looks like more work because you have to provide a bunch of methods that do nothing but call the Properties instance, but there are some subtle dangers in extending any concrete class. Even though Properties is likely to be very stable over tme, this "decorator" is safer in the long run.
Of course a quick look at the doc shows Sun already stepped up to the dangers by extending HashMap. It's their problem to assure that future changes to HashMap don't break Properties. Don't join them in the risk if you can help it.
[ December 04, 2004: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Nov 24, 2004
Hi, thank you all!
the solution suggested here is exactly what I need!
I didn't understand about the source code to API classes, is it somewhere in JDK???