Code example for Properties

Methods: setProperty, store

0
 
	public void setProperties(String key, String value)
	{ 
		if (value != null)
		{ 
			Properties props = new Properties();
			props.setProperty(key, value);
			setProperties(props);
		} 
	} 
 
	private Properties getProperties()
	{ 
		if (mProperties == null)
		{ 
			mProperties = getPro();
		} 
		return mProperties;
	} 
 
	private Properties getPro()
	{ 
		Properties props = new Properties();
		try 
		{ 
			InputStream in = new FileInputStream(properFile);
			props.load(in);
		} catch (IOException e)
		{ 
			e.printStackTrace();
		} 
		return props;
	} 
 
	private void setProperties(Properties p)
	{ 
		OutputStream out;
		try 
		{ 
			out = new FileOutputStream(properFile, false);
			p.store(out, null);
			out.flush();
		} catch (Exception e)
		{ 
			e.printStackTrace();
		}