All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.util.PropertyResourceBundle

java.lang.Object
   |
   +----java.util.ResourceBundle
           |
           +----java.util.PropertyResourceBundle

public class PropertyResourceBundle
extends ResourceBundle
PropertyResourceBundle supplies resources for a locale, using a set of static strings from a property file. To create the file, create a property file the keys (and their values) that you use in your source code in calls to ResourceBundle.getString, etc.

In the following example, the keys are of the form "s1"... The actual keys are entirely up to your choice, so long as they match what is in your source; just remember that they are case-sensitive.

Example:

     String[][] contents = {
     	{"s1", "3"},		// starting value in choice field
     	{"s2", "MeinDisk"},	// starting value in string field
     	{"s3", "3 Mar 96"},	// starting value in date field
     	{"s4", "Der disk '%1' a %0 a %2."},	// initial pattern
     	{"s5", "0"},		// first choice number
     	{"s6", "keine Datein"},	// first choice value
     	{"s7", "1"},		// second choice number
     	{"s8", "ein Datei"},	// second choice value
     	{"s9", "2"},		// third choice number
     	{"s10", "%0|3 Datein"},	// third choice value
     	{"s11", "Der Format worf ein Exception: %0"},	// generic exception message
     	{"s12", "ERROR"},	// what to show in field in case of error
     	{"s14", "Resulte"},	// label for formatted stuff
     	{"s13", "Dialogue"},	// standard font
     	{"s15", "Pattern"},	// label for standard pattern
     	{"s16", "1,3"}	// once we have serialization, can be real object
     };
  Properties props = new Properties();
  for (int i = 0; i < contents.length; ++i) {
  	props.put(contents[i][0],contents[i][1]);
  }
  FileOutputStream file = new FileOutputStream("MyResource_GE");
  props.save(file, "German Properties");
  file.close();
  

See Also:
ListResourceBundle

Constructor Index

 o PropertyResourceBundle(InputStream)
Creates a property resource

Method Index

 o handleGetObject(String)
Override of ResourceBundle, same semantics

Constructors

 o PropertyResourceBundle
  public PropertyResourceBundle(InputStream stream) throws IOException
Creates a property resource

Parameters:
file - property file to read from.

Methods

 o handleGetObject
  public Object handleGetObject(String key)
Override of ResourceBundle, same semantics

Overrides:
handleGetObject in class ResourceBundle

All Packages  Class Hierarchy  This Package  Previous  Next  Index