All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.dagere.kopeme.datastorage.YAMLDataLoader Maven / Gradle / Ivy

package de.dagere.kopeme.datastorage;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.yaml.snakeyaml.Yaml;


public class YAMLDataLoader implements DataLoader{

	private File f;
	
	public YAMLDataLoader( String filename )
	{
		f = new File( filename );
	}
	
	@Override
	public Map> getData() {
		try {
			if ( !f.exists() )
			{
				Map> m = new HashMap>();
				return m;
			}
			InputStream is = new FileInputStream(f);
			Yaml yaml = new Yaml();
			Object o = yaml.load(is);
			if ( o instanceof Map )
			{
				Map> m = (Map>) o;
				return m;
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy