// File: TestProperties2.java // // Author: Rahul Simha // Created: Sept 23, 1998 // // Illustrates using the Properties object // via a file. import java.util.*; import java.io.*; public class TestProperties2 { public static void main (String[] argv) { // Create an instance of a Properties class. Properties p = new Properties(); // Read from a text file with properties ("geodata"). try { FileInputStream f = new FileInputStream ("geodata"); // Use the "load" method in a Properties object. p.load (f); } catch (IOException e) { System.out.println ("Cannot open file"); System.exit(0); } // Retrieve property values. String cx = p.getProperty ("Circle1.center.x"); String cy = p.getProperty ("Circle1.center.y"); String r = p.getProperty ("Circle1.radius"); System.out.println ("Circle1: cx=" + cx + ", cy=" + cy + ", r=" + r); } }