Watch 6 Star 22 Fork 3

法欧特斯卡雷特 / mini-iniJavaApache-2.0

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
有些时候,可能你会需要使用java来操作以下ini配置文件,而此工具便可以支持你使用java对ini格式的配置文件进行一些方便快捷的操作。什么?有些处理不太符合你的预期?没关系,你完全可以通过实现一些指定接口来重新定义解析方案! spread retract

Clone or download
Notice: Creating folder will generate an empty file .keep, because not support in Git


codebeat badge version

What is this?

This is a mini util for .ini file.

My English is poor, but I still try to edit comments in English. I hope you can understand.

Most come from google translation.


and hope a star, Thanks~ ♪(´▽`)


gitee :

How to use?

First, Click the star button in the upper right corner to make some hidden content take effect. :P

Create project

Create project with:

version: img




compile group: 'love.forte', name: 'mini-ini', version: '${version}'

Read ini

You can see part of the code that appears below from Demo1.

See test.ini

// Get input stream
InputStream iniInput = Demo1.class.getClassLoader().getResourceAsStream("test.ini");

// Read by default buffered reader
IniReader ir = new BufferedIniReader();
Ini ini =;

// show

// to properties and show
ini.toProperties().forEach((k, v) -> {
    System.out.println(k + "=" + v);

Create/Write ini

You can see part of the code that appears below from Demo2.

 // Create an IniBuilder and
IniBuilder b = new IniBuilder()
        .plusComment("this is a test ini")
        .plusSection("sec1", "this is a section")
        .plusProperty("key1", "value")
        .plusProperty("key2", "value")
        .plusProperty("key3", "value")
        .plusProperty("key4", "value")
        .plusProperty("key5", "value")
        .plusProperty("key6", "value")
        .plusProperty("key1", "value")
        .plusProperty("key2", "value")
        .plusProperty("key3", "value")
        .plusProperty("key4", "value")
        .plusProperty("key5", "value")
        .plusProperty("key6", "value")

// Build ini
final Ini ini =;

// show

// Write to file
ini.write(Paths.get("F:\\test3.ini"), true);


  • IniElement implements the interface, which can be serialized. (1.1.0)
  • Ini inherits ArrayList<IniElement>, which can be serialized and used as a list.
  • IniProperty implements the interface Map.Entry<String, String>.
  • IniSection implements the interface List<IniProperty>, which can be used as a list.


You can customize (implement the interface) to achieve some additional parsing methods.

I provide some easy-to-implement (probably) interfaces to support user customization. If you want, you can also open source your additional implementations. If you open source, you can tell me, I will show the address in the README.

some interface or abstract class:

Ini elements like IniElementBaseElement or IniComment(Default implementation is IniCommentImpl)、IniProperty(Default implementation is IniPropertyImpl)、IniSection(Default implementation is IniSectionImpl).

Ini reader like IniReadableIniReader or Refer to the default implementation BufferedIniReader.

Ini formatter like IniFormatterIniFormatterFactoryElementFormatter.

You can refer to Demo3.


  • This project has no additional dependencies, so you should be able to use it directly by importing the jar package.

  • By default, when parsing an ini file, the content of the ini file is divided into several parts:

# comment
[section1] # comment
# comment
[section2] # comment
  • By default, the rules are:
    • section is wrapped by [], and there can be comments after the end.
    • comment starts with # and can be at the beginning of a line or the end of a section.
    • Property is a key-value pair under section, and cannot be followed by a comment.

I found a bug

Oh! nice! You can tell me through the issue, or submit the bug through branch submission. try to use simple English or Chinese. Thanks.


if you like this, Give me a star or a little pocket money~ if you don't, May consider helping me improve the code

Reward me:




My level is limited, please understand if there are any problems.

license: Apache License 2.0

Comments ( 0 )

Sign in for post a comment