public class Properties
extends java.lang.Object
Properties props = new Properties(); File file; //*************************************** // load properties that already exists //*************************************** if (existe_arquivo(arquivo)) { file = new File(arquivo, File.READ_WRITE); props.load(new DataStream(file)); file.close(); } //*************************************** props.put(propriedade,new Properties.Str(valor)); file = new File(arquivo, File.CREATE); props.save(new DataStream(file)); file.close();
Modifier and Type | Class and Description |
---|---|
static class |
Properties.Boolean
Implements a value of type boolean
|
static class |
Properties.Double
Implements a value of type double
|
static class |
Properties.Int
Implements a value of type int
|
static class |
Properties.Long
Implements a value of type long
|
static class |
Properties.Str
Implements a value of type String
|
static class |
Properties.Value
Represents a generic value that can be stored here.
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_PROPS
Avoids that the load method gets into an infinite loop if the file is
empty or corrupted.
|
Constructor and Description |
---|
Properties() |
Properties(java.lang.String[] keys,
Properties.Value[] values)
Stores the given keys/values pairs in a new Properties.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this property
|
java.lang.StringBuffer |
dumpKeysValues(java.lang.StringBuffer sb,
java.lang.String keyvalueSeparator,
java.lang.String lineSeparator)
Dumps the keys and values into the given StringBuffer.
|
Properties.Value |
get(java.lang.String key)
Get the value given the key from the hashtable that stores the properties.
|
Vector |
getKeys()
Returns a Vector with the current keys
|
void |
load(DataStream ds)
Load all properties from the given DataStream.
|
void |
load(DataStream ds,
boolean cleanBeforeLoad)
Load properties from the given DataStream.
|
void |
put(java.lang.String key,
Properties.Value v)
Put the given key/value pair in the hashtable that stores the properties.
|
void |
remove(java.lang.String key)
Remove a value from the property
|
void |
save(DataStream ds)
Save all properties in the given DataStream
|
int |
size()
Returns the number of properties
|
public static int MAX_PROPS
public Properties()
public Properties(java.lang.String[] keys, Properties.Value[] values)
public void put(java.lang.String key, Properties.Value v)
public Properties.Value get(java.lang.String key)
public int size()
public Vector getKeys()
public void clear()
public void remove(java.lang.String key)
public void save(DataStream ds) throws IOException
IOException
public void load(DataStream ds) throws IOException
IOException
public void load(DataStream ds, boolean cleanBeforeLoad) throws IOException
ds
- cleanBeforeLoad
- IOException
public java.lang.StringBuffer dumpKeysValues(java.lang.StringBuffer sb, java.lang.String keyvalueSeparator, java.lang.String lineSeparator)
sb
- The StringBuffer where the data will be dumped tokeyvalueSeparator
- The separator between the key and the value (E.G.: ": ")lineSeparator
- The separator placed after each key+value pair (E.G.: "\r\n"). The last separator is cut from the
StringBuffer.