- All Implemented Interfaces:
Serializable,Cloneable,Iterable<IniElement>,Collection<IniElement>,List<IniElement>,RandomAccess,SequencedCollection<IniElement>
Represents the in-memory structure of an INI file, extending
ArrayList<IniElement>. An empty line in the INI
file is represented by a null element in this list. To create an instance of this class programmatically, use
the INI builder.- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty list with an initial capacity of ten.IniSetting(int initialCapacity) Constructs an empty list with the specified initial capacity.IniSetting(Collection<? extends IniElement> c) Constructs a list containing the elements of the specified collection. -
Method Summary
Modifier and TypeMethodDescriptionConverts the INI data into aPropsobject using '.' as the delimiter between section names and keys.toProperties(String delimiter) Converts the INI data into aPropsobject.toString()Returns a string representation of the INI data, formatted as a valid INI file.voidWrites the INI content to aFileusing UTF-8 encoding.voidWrites the INI content to aFile.voidwrite(OutputStream out, boolean withComment) Writes the INI content to anOutputStreamusing UTF-8 encoding.voidwrite(OutputStream out, Charset charset, boolean withComment) Writes the INI content to anOutputStream.voidwrite(PrintStream print, boolean withComment) Writes the INI content to aPrintStream.voidWrites the INI content to aWriter.voidWrites the INI content to aPathusing UTF-8 encoding.voidWrites the INI content to aPath.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
IniSetting
public IniSetting()Constructs an empty list with an initial capacity of ten. -
IniSetting
public IniSetting(int initialCapacity) Constructs an empty list with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity of the list.
-
IniSetting
Constructs a list containing the elements of the specified collection.- Parameters:
c- the collection whose elements are to be placed into this list.
-
-
Method Details
-
toString
Returns a string representation of the INI data, formatted as a valid INI file.- Overrides:
toStringin classAbstractCollection<IniElement>- Returns:
- The INI content as a string.
-
toProperties
Converts the INI data into aPropsobject. The keys in the resulting properties will be a combination of the section name and the property key, joined by the specified delimiter.For example, with a delimiter of '.':
[se1] key1=value1
becomes a property with the key"se1.key1".- Parameters:
delimiter- The string to use for joining the section name and property key. If null, only the property key is used.- Returns:
- A
Propsobject representing the INI data.
-
toProperties
Converts the INI data into aPropsobject using '.' as the delimiter between section names and keys.- Returns:
- A
Propsobject. - See Also:
-
write
Writes the INI content to anOutputStream.- Parameters:
out- The output stream to write to.charset- The character set to use for encoding.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the INI content to anOutputStreamusing UTF-8 encoding.- Parameters:
out- The output stream to write to.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.- See Also:
-
write
Writes the INI content to aWriter.- Parameters:
writer- The writer to use.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the INI content to aPrintStream.- Parameters:
print- The print stream to write to.withComment- Iftrue, comments will be included in the output.
-
write
Writes the INI content to aFile.- Parameters:
file- The destination file.charset- The character set to use.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the INI content to aFileusing UTF-8 encoding.- Parameters:
file- The destination file.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the INI content to aPath.- Parameters:
path- The destination path.charset- The character set to use.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.
-
write
Writes the INI content to aPathusing UTF-8 encoding.- Parameters:
path- The destination path.withComment- Iftrue, comments will be included in the output.- Throws:
IOException- if an I/O error occurs.
-