// File: TestProperties.java // // Author: Rahul Simha // Created: Sept 23, 1998 // // Illustrates using the Properties object. import java.util.*; // "Properties" is in the // package java.util. import java.io.*; // For file I/O. public class TestProperties { public static void main (String[] argv) { // Create a new Properties object. Properties p = new Properties(); // Insert some properties. p.put ("Circle1.center.x", "100"); p.put ("Circle1.center.y", "250"); p.put ("Circle1.radius", "30"); // Note: both the property name and // the value are String's. p.put ("Circle2.center.x", "60"); p.put ("Circle2.center.y", "90"); p.put ("Circle2.radius", "10"); p.put ("Square1.topleft.x", "300"); p.put ("Square1.topleft.y", "400"); p.put ("Square1.side", "40"); // Print all the properties to the screen. p.save (System.out, "Geometric objects"); // Write the properties to text file called "geodata" try { FileOutputStream f = new FileOutputStream ("geodata"); p.save (f, "Geometric objects"); } catch (IOException e) { System.out.println ("Cannot open file"); System.exit(0); } } // "main" } // End of class "TestProperties"