Class IniFile
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescriptionLoads 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 SummaryModifier and TypeMethodDescription- static IniFile- createNewIniFile- (boolean isCaseSensitive, String fileName) Creates a new editable INI file.- static IniFile- createNewIniFile- (String fileName) Creates a new editable INI file.- boolean- deleteSection- (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.- boolean- reload- (boolean force) Reload internal state from external sources.- void- removeAllItems- (String section) Removes all items defined in a section.- boolean- renameSection- (String oldName, String newName) Renames a section in the INI file.- void- save- (OutputStream out) Saves the INI file to an OutputStream without closing it.- void- save2- (XOutputFile out) Saves the INI file to an open PhantomOutputFile without closing it.- void- saveFile()Saves all changes (if any) made to the file.- void- setCreateUntitledSectionHeadings- (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- IniFileThe constructor loads the contents of the file.- Throws:
- IOException- if an I/O error occurs.
- FileNotFoundException- if the file is not found.
 
- IniFileThe constructor loads the contents of the file.- Throws:
- IOException- if an I/O error occurs.
- FileNotFoundException- if the file is not found.
 
- IniFileThe constructor loads the contents of the file. Set- isEditableto- trueif 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.
 
- IniFilepublic IniFile- (boolean isCaseSensitive, String fileName, boolean isEditable) throws IOException, FileNotFoundException The constructor loads the contents of the file. Set- isEditableto- trueif 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.
 
- IniFileLoads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
- IOException- if an I/O error occurs.
 
- IniFileLoads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
- IOException- if an I/O error occurs.
 
- IniFileLoads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
- IOException- if an I/O error occurs.
 
- IniFileLoads the contents a the opened file (typically from a JAR or ZIP file).- Throws:
- IOException- if an I/O error occurs.
 
 
- Method Details- createNewIniFileCreates a new editable INI file.
- createNewIniFileCreates a new editable INI file.
- setCreateUntitledSectionHeadingspublic void setCreateUntitledSectionHeadings- (boolean on) Sets if untitled sections headings should be created or not.
- doCreateUntitledSectionHeadingspublic boolean doCreateUntitledSectionHeadings()Checked if untitled sections headings should be created.
- needsReloadpublic boolean needsReload()Check if this file needs to be reloaded.
- reloadReload 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
 
- getFileNameGets the file name of the ini file.
- getSectionsGets all the section elements in the file.
- getItemsGets all the item elements in a section.- Returns:
- null If section not found.
 
- getSectionItemsGets a copy of the hash table of a section.
- getSizeGets number of elements in a section.- Returns:
- 0 If section not found.
 
- getDataGets 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".
 
- getDataGets an item string in a section with default data if not found.
- getDataGets a integer value from an item.
- getDataGets a boolean value from an item.
- setItemSets 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.
- setItemSets 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.
- setItemSets 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.
- setItemSets 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.
- setItemsAdds 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.
- setItemsAdds 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.
- setItemsSets 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.
- setItemspublic 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.
- setItemsSets 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.
- setItemspublic 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.
- setItemsSets 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.
- setItemspublic 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.
- removeAllItemsRemoves all items defined in a section.
- deleteSectionRemoves 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.
 
- renameSectionRenames 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 set- newNameto- null. This will comment the section heading and remove all the uncommented items in it.- Returns:
- true for success; false for failure.
 
- hasChangedpublic boolean hasChanged()Checks if the INI file has changed and might need a "save".
- saveFileSaves 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.
 
- save2Saves the INI file to an open PhantomOutputFile without closing it.- Throws:
- IOException- if an I/O error occurs.
 
- saveSaves the INI file to an OutputStream without closing it.- Throws:
- IOException- if an I/O error occurs.