Files
HaE/src/main/java/burp/rule/utils/YamlTool.java

37 lines
966 B
Java
Raw Normal View History

2023-10-12 21:38:27 +08:00
package burp.rule.utils;
2023-10-19 22:43:29 +08:00
import java.nio.file.Files;
import java.nio.file.Paths;
2023-10-12 21:38:27 +08:00
import java.util.Map;
2023-10-18 00:49:02 +08:00
2023-10-12 21:38:27 +08:00
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.yaml.snakeyaml.representer.Representer;
/**
* @author EvilChen
*/
public class YamlTool {
public static Yaml newStandardYaml() {
DumperOptions dop = new DumperOptions();
dop.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Representer representer = new Representer();
return new Yaml(representer, dop);
}
public static Map<String, Object> loadYaml(String filePath) {
try {
2023-10-19 22:43:29 +08:00
InputStream inputStream = Files.newInputStream(Paths.get(filePath));
return newStandardYaml().load(inputStream);
} catch (Exception e) {
2023-10-12 21:38:27 +08:00
e.printStackTrace();
return null;
}
}
}