Class IniFile
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsConstructorDescriptionLoads the contents a the opened file (typically from a JAR or ZIP file).Loads the contents a the opened file (typically from a JAR or ZIP file).The constructor loads the contents of the file.The constructor loads the contents of the file.Loads the contents a the opened file (typically from a JAR or ZIP file).Loads the contents a the opened file (typically from a JAR or ZIP file).The constructor loads the contents of the file.The constructor loads the contents of the file.Method Summary
Modifier and TypeMethodDescriptionstatic IniFilecreateNewIniFile(boolean isCaseSensitive, String fileName) Creates a new editable INI file.static IniFilecreateNewIniFile(String fileName) Creates a new editable INI file.booleandeleteSection(String name) Removes a section from the INI file.booleanChecked if untitled sections headings should be created.Gets an item string in a section.booleanGets a boolean value from an item.intGets a integer value from an item.Gets an item string in a section with default data if not found.Gets the file name of the ini file.Gets all the item elements in a section.getSectionItems(String section) Gets a copy of the hash table of a section.Gets all the section elements in the file.intGets number of elements in a section.booleanChecks if the INI file has changed and might need a "save".booleanCheck if this file needs to be reloaded.booleanreload(boolean force) Reload internal state from external sources.voidremoveAllItems(String section) Removes all items defined in a section.booleanrenameSection(String oldName, String newName) Renames a section in the INI file.voidsave(OutputStream out) Saves the INI file to an OutputStream without closing it.voidsave2(XOutputFile out) Saves the INI file to an open PhantomOutputFile without closing it.voidsaveFile()Saves all changes (if any) made to the file.voidsetCreateUntitledSectionHeadings(boolean on) Sets if untitled sections headings should be created or not.voidSets the topic and item to a specific boolean (0 or 1).voidSets the topic and item to a specific integer.voidSets the topic and item to a specific string.voidSets the topic and item to a specific string.voidAdds a set of items that does not include the equal sign to a topic.voidAdds a set of items that does not include the equal sign to a topic.voidSets the topic and item to a specific string.voidSets the topic and item to a specific string.voidSets the topic and item to a specific string.voidSets the topic and item to a specific string.voidSets the topic and item to a specific string.voidSets the topic and item to a specific string.
Constructor Details
IniFile
The constructor loads the contents of the file.- Throws:
IOException- if an I/O error occurs.FileNotFoundException- if the file is not found.
IniFile
The constructor loads the contents of the file.- Throws:
IOException- if an I/O error occurs.FileNotFoundException- if the file is not found.
IniFile
The constructor loads the contents of the file. SetisEditabletotrueif the contents of the file may be changed and later saved.- Throws:
IOException- if an I/O error occurs.FileNotFoundException- if the file is not found.
IniFile
public IniFile(boolean isCaseSensitive, String fileName, boolean isEditable) throws IOException, FileNotFoundException The constructor loads the contents of the file. SetisEditabletotrueif the contents of the file may be changed and later saved.- Throws:
IOException- if an I/O error occurs.FileNotFoundException- if the file is not found.
IniFile
Loads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
IOException- if an I/O error occurs.
IniFile
Loads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
IOException- if an I/O error occurs.
IniFile
Loads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
IOException- if an I/O error occurs.
IniFile
Loads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
IOException- if an I/O error occurs.
Method Details
createNewIniFile
Creates a new editable INI file.createNewIniFile
Creates a new editable INI file.setCreateUntitledSectionHeadings
public void setCreateUntitledSectionHeadings(boolean on) Sets if untitled sections headings should be created or not.doCreateUntitledSectionHeadings
public boolean doCreateUntitledSectionHeadings()Checked if untitled sections headings should be created.needsReload
public boolean needsReload()Check if this file needs to be reloaded.reload
Reload internal state from external sources.- Parameters:
force- Force the reload flag.- Returns:
- true for success, false for nothing done (failure is reported by IOException).
- Throws:
IOException
getFileName
Gets the file name of the ini file.getSections
Gets all the section elements in the file.getItems
Gets all the item elements in a section.- Returns:
- null If section not found.
getSectionItems
Gets a copy of the hash table of a section.getSize
Gets number of elements in a section.- Returns:
- 0 If section not found.
getData
Gets an item string in a section.- Returns:
- null If no item is found or if the item did not contain any data (i.e. as "ItemDoesNotHave An EqualSign".
getData
Gets an item string in a section with default data if not found.getData
Gets a integer value from an item.getData
Gets a boolean value from an item.setItem
Sets the topic and item to a specific integer. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItem
Sets the topic and item to a specific boolean (0 or 1). If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItem
Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItem
Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.This method doesn't do anything if the item already has the specified data.
Use the method
saveFileto save all changes made to the file.setItems
Adds a set of items that does not include the equal sign to a topic. If the topic doesn't exist, it will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
Adds a set of items that does not include the equal sign to a topic. If the topic doesn't exist, it will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
public void setItems(String section, Hashtable<String, String> itemDataPairs, String newSectionHeadingText) Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
public void setItems(String section, HashMap<String, String> itemDataPairs, String newSectionHeadingText) Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.setItems
public void setItems(String section, Set<Map.Entry<String, String>> entries, String newSectionHeadingText) Sets the topic and item to a specific string. If the topic or item doesn't exist, they will be created. Note that the topic may be in any character case (and any existing entry will preserve the original case). New topics/items are added at the end of the topic or the file respectively.Use the method
saveFileto save all changes made to the file.removeAllItems
Removes all items defined in a section.deleteSection
Removes a section from the INI file. This will comment the section heading and remove all the uncommented items in it.- Returns:
- true for success; false for failure.
renameSection
Renames a section in the INI file. The section should not contain the [brackets]. To remove a section from the INI file, i.e. to comment it, just setnewNametonull. This will comment the section heading and remove all the uncommented items in it.- Returns:
- true for success; false for failure.
hasChanged
public boolean hasChanged()Checks if the INI file has changed and might need a "save".saveFile
Saves all changes (if any) made to the file. Before the save is performed, a backup file as "filename[.extension].bak" is created.- Throws:
IOException- if an I/O error occurs.
save2
Saves the INI file to an open PhantomOutputFile without closing it.- Throws:
IOException- if an I/O error occurs.
save
Saves the INI file to an OutputStream without closing it.- Throws:
IOException- if an I/O error occurs.