public class Ini extends Object
| Constructor and Description |
|---|
Ini()
default constructor
|
| Modifier and Type | Method and Description |
|---|---|
Collection<String> |
getKeys(String section)
get the keys from a particular section.
|
Map<String,Object> |
getSection(String section)
return the section as a map.
|
Collection<String> |
getSections()
get the sections from the ini file.
|
Map<String,Object> |
getSectionSortedByKey(String section)
return the section as a map; sorted by key
|
Map<String,Object> |
getSectionWithKeysThatMatchFunction(String section,
Predicate<Map.Entry<String,Object>> filter)
get a subset of a section where all the keys match the provided filter
|
Map<String,Object> |
getSectionWithKeysWithPrefix(String section,
String prefix)
get a subset of a section where all the keys match the provided prefix
|
Map<String,Object> |
getSectionWithKeysWithRegex(String section,
String regex)
get a subset of a section where all the keys match the provided prefix
|
Object |
getValue(String section,
String key)
return a value from the nested structure as an object
|
<T> T |
getValue(String section,
String key,
Class<T> type)
return a value from the nested structure and cast it to the specified type.
|
boolean |
hasKey(String section,
String key)
return true if the section and section key exists, false otherwise
|
void |
load(File file)
default constructor with
File |
void |
load(InputStream inputStream)
default constructor with an
InputStream |
void |
load(String string)
default constructor with
String |
void |
merge(Ini ini)
|
void |
putValue(String section,
String key,
Object value)
store new values in the ini
|
void |
putValues(String sectionKey,
Map<String,Object> sectionEntries)
put multiple key/value pairs into a section.
|
Map<String,Object> |
removeSection(String section)
Removes the specified section.
|
Object |
removeSectionKey(String section,
String key)
Removes the specified key in the specified section.
|
void |
store(OutputStream outputStream,
String comments)
store the ini to an outputstream
|
void |
store(Writer writer,
String comments)
store the ini to a writer
|
public void load(InputStream inputStream) throws IOException
InputStreaminputStream - the ini file as an input streamIOException - thrown when there is an error processing the ini.public void load(File file) throws IOException
Filefile - the ini fileIOException - thrown when there is an error processing the ini.public void load(String string) throws IOException
Stringstring - the contents of the ini fileIOException - thrown when there is an error processing the ini.public void merge(Ini ini)
Ini with another Ini. If there are any merge conflicts the passed in Ini
will take precedence.ini - the ini to mergepublic boolean hasKey(String section, String key)
section - the desired sectionkey - the key in the sectionpublic Object getValue(String section, String key)
section - the desired sectionkey - the desired key in the sectionpublic <T> T getValue(String section, String key, Class<T> type)
T - the generic for the typesection - the desired sectionkey - the key in the sectiontype - the desired typepublic Collection<String> getSections()
public Collection<String> getKeys(String section)
section - the desired sectionpublic Map<String,Object> getSection(String section)
section - the desired sectionpublic Map<String,Object> getSectionSortedByKey(String section)
section - the desired sectionpublic Map<String,Object> getSectionWithKeysWithPrefix(String section, String prefix)
section - the desired sectionprefix - that the key starts withpublic Map<String,Object> getSectionWithKeysThatMatchFunction(String section, Predicate<Map.Entry<String,Object>> filter)
section - filter - the filter that the Map.Entry in she specified section must matchpublic Map<String,Object> getSectionWithKeysWithRegex(String section, String regex)
section - the desired sectionregex - that matches the keypublic void putValue(String section, String key, Object value)
section - the desired sectionkey - the key in the sectionvalue - the value to store for that keypublic void putValues(String sectionKey, Map<String,Object> sectionEntries)
sectionEntries - public void store(OutputStream outputStream, String comments) throws IOException
outputStream - the outputstream to write tocomments - the comments to put at the top of the fileIOException - if there is an error writing to the outputstreampublic void store(Writer writer, String comments) throws IOException
writer - the writer to usecomments - commments to put at the top of the file.IOException - if there is an error writing to the writerpublic Map<String,Object> removeSection(String section)
section - the section to removepublic Object removeSectionKey(String section, String key)
section - the section to removekey - the key in that section to removeCopyright © 2024. All rights reserved.