java 读取yaml_java读取YAML文件

loadString:

type:link

locater:kw

rootLocation: root

timeout: 15

package com.test;

import org.ho.yaml.Yaml;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.util.HashMap;

import org.testng.Assert;

public class Test2 {

/**

* @param args

*/

public void getTest() {

Assert.assertEquals(1,2);

System.out.println("1234");

}

public void getYamlFile() throws FileNotFoundException{

File f = new File("src/com/test/Test2.yaml");

System.out.println(f.getAbsolutePath());

HashMap ml = Yaml.loadType(new FileInputStream(f.getAbsolutePath()), HashMap.class);

System.out.println(ml.size());

System.out.println(((HashMap) ml.get("loadString")).get("locater"));

}

public static void main(String[] args) throws FileNotFoundException {

Test2 t = new Test2();

t.getYamlFile();

}

}

你可能感兴趣的:(java,读取yaml)