RegistryKey.getValue

Overview | Methods | This Package | All Packages

RegistryKey.getValue

Retrieves the specified value from the registry.

Syntax

public Object getValue( String name )

public Object getValue( String name, Object defaultValue )

Parameters

name

A String object that contains the name of value to retrieve.

defaultValue

The value to return if name does not exist.

Return Value

Returns an object that represents the data associated with the value.

Remarks

Use the getValue method to retrieve data from the registry for the specified value. The data returned from the registry must be cast to the proper Java data type. Use the second version of this method to specify the data that will be returned if the specified value entry does not exist in the registry. If the first version of this method is used, null is returned if the value entry does not exist in the registry. To get a list of all the value names stored for the current key, use the getValueNames method.

The following example illustrates how to write a Font object to the registry using the setValue method and getTextFromValue method in the Font.Editor class. It also shows how to restore the Font object from the registry using the getValue method and the getValueFromText method in the Font.Editor class.

Font.Editor tempEditor = new Font.Editor()

RegistryKey myKey =
Registry.CURRENT_USER.createSubKey("Software\\MyCompany\\MyProduct");

//Store the Font to the registry 
myKey.setValue("MyValue", tempEditor.getTextFromValue( new Font("Arial", 11.0f, FontSize.CHARACTERHEIGHT)));

//Restore the Font from the registry 
Font myFont = (Font)tempEdit.getValueFromText((String) myKey.getValue("MyValue"));

See Also   getValueCount