com.neko233.skilltree.commons.configFile.ConfFile233 Maven / Gradle / Ivy
package com.neko233.skilltree.commons.configFile;
import com.neko233.skilltree.commons.configFile.utils.FilePahUtils;
import com.neko233.skilltree.commons.core.utils.ResourcesJdkUtils233;
import lombok.Getter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* xxx.conf 文件读取
*
* @author SolarisNeko on 2023-10-01
*/
public class ConfFile233 {
public static void main(String[] args) {
try {
ConfFile233 confFile = new ConfFile233();
confFile.reload(ResourcesJdkUtils233.getResourceFile("my.conf")); // 替换为您的 .conf 文件路径
Map properties = confFile.getProperties();
for (Map.Entry entry : properties.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static final Pattern PROPERTY_PATTERN = Pattern.compile("(\\w+)\\s*=\\s*(.*)");
private static final Pattern CONTAINER_PATTERN = Pattern.compile("(\\w+)\\s*\\{");
@Getter
private Map properties = new HashMap<>();
private Stack