All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lejos.internal.io.SystemSettings Maven / Gradle / Ivy

Go to download

leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.

The newest version!
package lejos.internal.io;

public class SystemSettings {

	/**
	 * Get the value for a leJOS persistent setting as a String
	 * 
	 * @param key the name of the setting
	 * @param defaultValue the default value
	 * @return the value
	 */
	public static String getStringSetting(String key, String defaultValue) {
		return Settings.getProperty(key, defaultValue);
	}
	
	/**
	 * Get the value for a leJOS persistent setting as an Integer
	 * 
	 * @param key the name of the setting
	 * @param defaultValue the default value
	 * @return the value
	 */
	public static int getIntSetting(String key, int defaultValue) {
		String s = getStringSetting(key, null);
		if (s == null)
			return defaultValue;
			
		try {
			return Integer.parseInt(s);
		} catch (NumberFormatException e) {
			return defaultValue;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy