Home | Gaming | Programming | Play Online | Submit Article | Submit BETA | Advertise | Contact | Keyword Query | Trade Games
Games++ Games & Game Programming

GAMES++
Games++ Home
Games++ Gaming
Games++ Programming
Beta Testing Games
Free Online Games
Hints & Cheats

BROWSER UTILITIES
E-mail This Page
Add to Favorites

SITE SEARCH

Web Games++

AFFILIATES
Cheat Codes
Trickster Wiki
Game Ratings
Trade Games
Gameboy Cheats
PlayStation Cheats
BlackBerry Games
Photoshop Tutorials
Illustrator Tutorials
ImageReady Tutorials
Tutorial Bus
Fresh Tutorials

ADVERTISEMENT

Use The Registry to Store Information

Java: How To

With JDK1.4, the Preferences can use the Windows registry :

import java.util.prefs.Preferences;

public class UsingReg 
{

	public static final String REALKEY= "com.rgagnon.foo";

	public static void main(String[] args)
	{
		new UsingReg().doit();
	}

	public void doit() 
	{
		// write into HKCU\Software\Javasoft\Prefs\com.rgagnon.foo
		Preferences p = Preferences.userRoot();
		p.put(REALKEY, "bar");

		// read back from HKEY_CURRENT_USER
		System.out.println(p);
		System.out.println(p.get(REALKEY, "HKCU houston we have a problem"));

		// write into HKLM\Software\Javasoft\Prefs\com.rgagnon.foo
		p = Preferences.systemRoot();
		p.put(REALKEY, "barbar");

		// read back from HKEY_LOCAL_MACHINE
		System.out.println(p);
		System.out.println(p.get(REALKEY, "HKLM houston we have a problem"));
	}
}

Copyright © 1998-2007, Games++ All rights reserved. | Privacy Policy