web123456

java SpringBoot create yaml file externally

// 1. Set the yml format, generally use the favorite format

DumperOptions dumperOptions = new DumperOptions();

(.BLOCK);

// 2. Create FileWriter

// Put your own path

String configPath = "D:\\code\\java\\demo3\\StudentDemo\\vhost\\";

FileWriter fileWriter = null;

try {

fileWriter = new FileWriter(new File(configPath));

} catch (IOException e) {

();

}

// 3. Create a yaml class

//YAML class is the entry point of the API

Yaml yamlt = new Yaml(dumperOptions);

//The yml file is stored using LinkedHashMap

LinkedHashMap<String, Object> ymlMap = new LinkedHashMap<>();

//Use the put method to add content

int index = 2;

int numt = 57567;

String randStry = "ijogugugy";

("index", index);

("num", numt);

("randStr", randStry);

//Dump method generates yaml

(ymlMap, fileWriter);