|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.equanda.util.IniFile
public class IniFile
Class to manipulate .ini files. Keys can be case dependent or case independent. Comments are discarded. File is kept in memory and needs to be explicitly saved.
Constructor Summary | |
---|---|
IniFile()
Creates a new reference to an .ini file. |
|
IniFile(boolean useCase)
|
|
IniFile(File file)
Creates a new reference to an INI file. |
|
IniFile(InputStream s)
Creates a new reference to an INI file. |
|
IniFile(Reader r)
Creates a new reference to an INI file. |
|
IniFile(String filename)
Creates a new reference to an .ini file. |
|
IniFile(String filename,
boolean useCase)
Creates a new reference to an .ini file. |
Method Summary | |
---|---|
void |
addSection(String section)
Creates a new section in the .ini file. |
void |
addValue(String section,
String key,
String value)
Add a key/value pair |
Hashtable<String,Hashtable<String,String>> |
getAll()
Allows the reading of the entire .ini file. |
Hashtable<String,String> |
getSection(String section)
Allows the reading of an entire section of configuration data. |
Enumeration<String> |
getSectionKeys(String section)
Get all the keys in a particular section |
Enumeration<String> |
getSectionNames()
Get an anumeration with all the section names |
String |
getValue(String section,
String key)
Read a specific key/value pair |
boolean |
isEmpty()
Check whether the .ini file has something in it. |
void |
removeAll()
Clear .ini file |
void |
removeSection(String section)
Remove a section including all keys. |
void |
removeValue(String section,
String key)
Removes a key/value pair from given section |
void |
save()
Save (overwrite) .ini file |
void |
save(String file)
Writes out the current data to a file. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IniFile()
public IniFile(boolean useCase)
public IniFile(String filename) throws IOException
filename
- The filename of the .ini file.
IOException
- if anything goes wrong during read.public IniFile(String filename, boolean useCase) throws IOException
filename
- The filename of the .ini file.useCase
- should tags be case dependent?
IOException
- if anything goes wrong during read.public IniFile(File file) throws IOException
file
- A File object for the INI file.
IOException
- if anything goes wrong during read.public IniFile(Reader r) throws IOException
r
- a reader which contains the INI file.
IOException
- if anything goes wrong during read.public IniFile(InputStream s) throws IOException
s
- an InputStream which contains the INI file.
IOException
- if anything goes wrong during read.Method Detail |
---|
public boolean isEmpty()
public String getValue(String section, String key)
section
- section namekey
- The key for which the value needs to be retrieved
public Enumeration<String> getSectionKeys(String section)
section
- section name
public Hashtable<String,String> getSection(String section)
section
- section name
public Hashtable<String,Hashtable<String,String>> getAll()
public void addValue(String section, String key, String value)
section
- section name, will be created if newkey
- keyvalue
- valuepublic void addSection(String section)
section
- section namepublic void removeValue(String section, String key)
section
- section that the key and value is in.key
- The key to be removed.public void removeSection(String section)
section
- section to removepublic void removeAll()
public void save() throws IOException
IOException
- if an error occurs while writing.public void save(String file) throws IOException
file
- The file to save to.
IOException
- if an error occurs while writing.public Enumeration<String> getSectionNames()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |