public class IniFile extends Object
Constructor and Description |
---|
IniFile(boolean isCaseSensitive,
PhantomFile in)
Loads the contents a the opened file (typically from a JAR or ZIP file).
|
IniFile(boolean isCaseSensitive,
PhantomFile in,
boolean isEditable)
Loads the contents a the opened file (typically from a JAR or ZIP file).
|
IniFile(boolean isCaseSensitive,
String fileName)
The constructor loads the contents of the file.
|
IniFile(boolean isCaseSensitive,
String fileName,
boolean isEditable)
The constructor loads the contents of the file.
|
IniFile(PhantomFile in)
Loads the contents a the opened file (typically from a JAR or ZIP file).
|
IniFile(PhantomFile in,
boolean isEditable)
Loads the contents a the opened file (typically from a JAR or ZIP file).
|
IniFile(String fileName)
The constructor loads the contents of the file.
|
IniFile(String fileName,
boolean isEditable)
The constructor loads the contents of the file.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
doCreateUntitledSectionHeadings()
Checked if untitled sections headings should be created.
|
String |
getData(String section,
String item)
Gets an item string in a section.
|
boolean |
getData(String section,
String item,
boolean defaultData)
Gets a boolean value from an item.
|
int |
getData(String section,
String item,
int defaultData)
Gets a integer value from an item.
|
String |
getData(String section,
String item,
String defaultData)
Gets an item string in a section with default data if not found.
|
String |
getFileName()
Gets the file name of the ini file.
|
Enumeration<String> |
getItems(String section)
Gets all the item elements in a section.
|
HashMap<String,String> |
getSectionItems(String section)
Gets a copy of the hash table of a section.
|
Enumeration<String> |
getSections()
Gets all the section elements in the file.
|
int |
getSize(String section)
Gets number of elements in a section.
|
boolean |
hasChanged()
Checks if the INI file has changed and might need a "save".
|
boolean |
needsReload()
Check if this file needs to be reloaded.
|
int |
reload()
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(PhantomOutputFile 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.
|
void |
setItem(String section,
String item,
boolean data)
Sets the topic and item to a specific boolean (0 or 1).
|
void |
setItem(String section,
String item,
int data)
Sets the topic and item to a specific integer.
|
void |
setItem(String section,
String item,
String data)
Sets the topic and item to a specific string.
|
void |
setItem(String section,
String item,
String data,
String newSectionHeadingText)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
HashMap<String,String> itemDataPairs)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
HashMap<String,String> itemDataPairs,
String newSectionHeadingText)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
Hashtable<String,String> itemDataPairs)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
Hashtable<String,String> itemDataPairs,
String newSectionHeadingText)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
Set<Map.Entry<String,String>> entries)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
Set<Map.Entry<String,String>> entries,
String newSectionHeadingText)
Sets the topic and item to a specific string.
|
void |
setItems(String section,
String[] items)
Adds a set of items that does not include the equal sign to a topic.
|
void |
setItems(String section,
String[] items,
String newSectionHeadingText)
Adds a set of items that does not include the equal sign to a topic.
|
void |
updateLastModified()
Updates the last modification time if set, used for the Editor.
|
public IniFile(String fileName) throws IOException, FileNotFoundException
IOException
- if an I/O error occurs.FileNotFoundException
- if the file is not found.public IniFile(boolean isCaseSensitive, String fileName) throws IOException, FileNotFoundException
IOException
- if an I/O error occurs.FileNotFoundException
- if the file is not found.public IniFile(String fileName, boolean isEditable) throws IOException, FileNotFoundException
isEditable
to
true
if the contents of the file may be changed and later saved.IOException
- if an I/O error occurs.FileNotFoundException
- if the file is not found.public IniFile(boolean isCaseSensitive, String fileName, boolean isEditable) throws IOException, FileNotFoundException
isEditable
to
true
if the contents of the file may be changed and later saved.IOException
- if an I/O error occurs.FileNotFoundException
- if the file is not found.public IniFile(PhantomFile in) throws IOException
IOException
- if an I/O error occurs.public IniFile(boolean isCaseSensitive, PhantomFile in) throws IOException
IOException
- if an I/O error occurs.public IniFile(PhantomFile in, boolean isEditable) throws IOException
IOException
- if an I/O error occurs.public IniFile(boolean isCaseSensitive, PhantomFile in, boolean isEditable) throws IOException
IOException
- if an I/O error occurs.public static IniFile createNewIniFile(String fileName)
public static IniFile createNewIniFile(boolean isCaseSensitive, String fileName)
public void setCreateUntitledSectionHeadings(boolean on)
public boolean doCreateUntitledSectionHeadings()
public boolean needsReload()
public int reload() throws IOException
IOException
public String getFileName()
public Enumeration<String> getSections()
public Enumeration<String> getItems(String section)
public HashMap<String,String> getSectionItems(String section)
public int getSize(String section)
public String getData(String section, String item)
public String getData(String section, String item, String defaultData)
public int getData(String section, String item, int defaultData)
public boolean getData(String section, String item, boolean defaultData)
public void setItem(String section, String item, int data)
Use the method saveFile
to save all changes made to the file.
public void setItem(String section, String item, boolean data)
Use the method saveFile
to save all changes made to the file.
public void setItem(String section, String item, String data)
Use the method saveFile
to save all changes made to the file.
public void setItem(String section, String item, String data, String newSectionHeadingText)
This method doesn't do anything if the item already has the specified data.
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, String[] items)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, String[] items, String newSectionHeadingText)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, Hashtable<String,String> itemDataPairs)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, Hashtable<String,String> itemDataPairs, String newSectionHeadingText)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, HashMap<String,String> itemDataPairs)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, HashMap<String,String> itemDataPairs, String newSectionHeadingText)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, Set<Map.Entry<String,String>> entries)
Use the method saveFile
to save all changes made to the file.
public void setItems(String section, Set<Map.Entry<String,String>> entries, String newSectionHeadingText)
Use the method saveFile
to save all changes made to the file.
public void removeAllItems(String section)
public boolean deleteSection(String name)
public boolean renameSection(String oldName, String newName)
newName
to null
.
This will comment the section heading and remove all the uncommented
items in it.public boolean hasChanged()
public void saveFile() throws IOException
IOException
- if an I/O error occurs.public void save2(PhantomOutputFile out) throws IOException
IOException
- if an I/O error occurs.public void save(OutputStream out) throws IOException
IOException
- if an I/O error occurs.public void updateLastModified()
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.