Следующий код предназначен для чтения файла .yaml в java. На самом деле я хочу проанализировать значения файла на карте и получить доступ к его значениям.
public static void main(String[] args) {
// The path of your YAML file.
final String fileName = "test.yml";
ArrayList<String> key = new ArrayList<String>();
ArrayList<String> value = new ArrayList<String>();
ArrayList<Object> obj = new ArrayList<Object>();
opencvmatrix ob = new opencvmatrix();
Yaml yaml = new Yaml();
try {
InputStream ios = new FileInputStream(new File(fileName));
// Parse the YAML file and return the output as a series of Maps and Lists
Map< String, Object> result = (Map< String, Object>) yaml.load(ios);
for (Object name : result.keySet()) {
key.add(name.toString());
obj.add(result.get(name));
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(key + " " + obj.get(0).getClass());
}
Синтаксис файла можно найти здесь: .yml. obje.get (0) .getClass () возвращает тип класса считываемых значений и возвращает объект opencvmatrix. Как я могу получить доступ к этому файлу? Когда я печатаю System.out.println (key + "" + obj); Я получил:
[mean, eigenvalues, eigenvectors, projections, labels] [opencvmatrix@254927,
opencvmatrix@1e5c67f, opencvmatrix@4ace42, [opencvmatrix@12b710e, opencvmatrix@10b6d81,
opencvmatrix@142691b,...
Как я могу получить доступ к этому адресу ??