Package net.sf.antcontrib.inifile
Class IniFile
- java.lang.Object
-
- net.sf.antcontrib.inifile.IniFile
-
public class IniFile extends java.lang.Object
Class representing a windows style .ini file.- Author:
- Matthew Inger
-
-
Constructor Summary
Constructors Constructor Description IniFile()
Create a new IniFile object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getProperty(java.lang.String section, java.lang.String property)
Gets a named property from a specific sectionIniSection
getSection(java.lang.String name)
Gets the IniSection with the given namejava.util.List
getSections()
Gets the List of IniSection objects contained in this IniFilevoid
read(java.io.Reader reader)
Reads from a Reader into the current IniFile instance.void
removeProperty(java.lang.String section, java.lang.String property)
Removes a property from a section.void
removeSection(java.lang.String name)
Removes an entire section from the IniFilevoid
setProperty(java.lang.String section, java.lang.String property, java.lang.String value)
Sets the value of a property in a given section.void
setSection(IniSection section)
Sets an IniSection object.void
write(java.io.Writer writer)
Writes the current iniFile instance to a Writer object for serialization.
-
-
-
Method Detail
-
getSections
public java.util.List getSections()
Gets the List of IniSection objects contained in this IniFile- Returns:
- a List of IniSection objects
-
getSection
public IniSection getSection(java.lang.String name)
Gets the IniSection with the given name- Parameters:
name
- the name of the section
-
setSection
public void setSection(IniSection section)
Sets an IniSection object. If a section with the given name already exists, it is replaced with the passed in section.- Parameters:
section
- The section to set.
-
removeSection
public void removeSection(java.lang.String name)
Removes an entire section from the IniFile- Parameters:
name
- The name of the section to remove
-
getProperty
public java.lang.String getProperty(java.lang.String section, java.lang.String property)
Gets a named property from a specific section- Parameters:
section
- The name of the sectionproperty
- The name of the property- Returns:
- The property value, or null, if either the section or property does not exist.
-
setProperty
public void setProperty(java.lang.String section, java.lang.String property, java.lang.String value)
Sets the value of a property in a given section. If the section does not exist, it is automatically created.- Parameters:
section
- The name of the sectionproperty
- The name of the propertyvalue
- The value of the property
-
removeProperty
public void removeProperty(java.lang.String section, java.lang.String property)
Removes a property from a section.- Parameters:
section
- The name of the sectionproperty
- The name of the property
-
write
public void write(java.io.Writer writer) throws java.io.IOException
Writes the current iniFile instance to a Writer object for serialization.- Parameters:
writer
- The writer to write to- Throws:
java.io.IOException
-
read
public void read(java.io.Reader reader) throws java.io.IOException
Reads from a Reader into the current IniFile instance. Reading appends to the current instance, so if the current instance has properties, those properties will still exist.- Parameters:
reader
- The reader to read from.- Throws:
java.io.IOException
-
-