Chapter 20 (Apache web server for windows) Java Utilities Package and Bit Manipulation
Chapter 20 Java Utilities Package and Bit Manipulation 1173 219 } // end method ListProperties 220 221 // display String in statusLabel label 222 public void showstatus( String s ) 223 { 224 statusLabel.setText( s ); 225 } 226 227 // execute application 228 public static void main( String args[] ) 229 { 230 PropertiesTest application = new PropertiesTest(); 231 232 application.setDefaultCloseOperation( 233 JFrame.EXIT_ON_CLOSE ); 234 } 235 236 } // end class PropertiesTest Fig. 20.4 Demonstrating class Properties(part 6 of 6). Line 25 uses the no-argument constructor to create an empty Propertiestable with no default properties. Class Properties also provides an overloaded constructor that receives a reference to a Propertiesobject containing default property values. Lines 68 69 call Propertiesmethod setPropertyto store a value for the specified key. If the key does not exist in the table, setProperty returns null; otherwise, it returns the previous value for that key. Lines 116 117 call Properties method getProperty to locate the value associated with the specified key. If the key is not found in this Properties object, get- Propertyuses the one in the default Propertiesobject (if there is one). The process continues recursively until there are no more default Propertiesobjects (remember that every Properties object can be initialized with a default Properties object), at which point getPropertyreturns null. An overloaded version of this method receives two arguments, the second of which is the default value to return if getPropertycannot locate the key. Line 150 calls Properties method store to save the contents of the Propertiesobject to the OutputStreamobject specified as the first argument (in this case, a FileOutputStream). The String argument is a description of the Properties object. Class Properties also provides method list, which takes a PrintStream argument. This method is useful for displaying the set of properties.
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision shared web hosting services