当前位置: 首页>>代码示例>>Java>>正文


Java YamlWriter.close方法代码示例

本文整理汇总了Java中com.esotericsoftware.yamlbeans.YamlWriter.close方法的典型用法代码示例。如果您正苦于以下问题:Java YamlWriter.close方法的具体用法?Java YamlWriter.close怎么用?Java YamlWriter.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.esotericsoftware.yamlbeans.YamlWriter的用法示例。


在下文中一共展示了YamlWriter.close方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
@Override
public void save(T object) {
    try {
        YamlWriter writer = new YamlWriter(new FileWriter(getFile()));
        writer.getConfig().writeConfig.setIndentSize(2);
        writer.getConfig().writeConfig.setAutoAnchor(false);
        writer.getConfig().writeConfig.setWriteDefaultValues(true);
        writer.getConfig().writeConfig.setWriteRootTags(false);
        writer.getConfig().writeConfig.setWriteClassname(YamlConfig.WriteClassName.NEVER);

        writer.write(object);
        writer.close();
    } catch (IOException exception) {
        exception.printStackTrace();
    }
}
 
开发者ID:b0atnet,项目名称:torsion,代码行数:17,代码来源:YMLFileParser.java

示例2: saveTokensToFile

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
protected void saveTokensToFile(TargetInfos targetInfos) {
    final File tokensFile = getTokensFile();
    tokensFile.getParentFile().mkdirs();
    try {
        FileWriter fileWriter = new FileWriter(tokensFile);

        YamlConfig config = new YamlConfig();
        config.writeConfig.setAlwaysWriteClassname(false);
        config.writeConfig.setWriteRootElementTags(false);
        config.writeConfig.setWriteRootTags(false);
        config.writeConfig.setExplicitFirstDocument(true);
        YamlWriter yamlWriter = new YamlWriter(fileWriter, config);

        yamlWriter.write(targetInfos);

        yamlWriter.close();
        fileWriter.close();
    } catch (IOException e) {
        throw new RuntimeException("An error occurred writing the tokens file at " +
                tokensFile.getPath() + ":" + e.getMessage(), e);
    }
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:23,代码来源:TokensFile.java

示例3: concatCustomAndAddedTypes

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
private Map<String, ?> concatCustomAndAddedTypes() throws Exception {
	Map customTypesMap = new LinkedHashMap<>(); // LinkedHashMap keeps the insertion order 
	Map nodes = new HashMap<>();
	Map capabilities = new HashMap<>();
	Map relationships = new HashMap<>();
	Map policies = new HashMap<>();
	readCustomAndAddedTypesInGivenDirectory("C:/Users/schallit/workspace-tosca2/plugins/org.eclipse.cmf.occi.tosca.parser/tosca-types/custom-types/", 
			nodes, capabilities, relationships, policies);
	readCustomAndAddedTypesInGivenDirectory("C:/Users/schallit/workspace-tosca2/plugins/org.eclipse.cmf.occi.tosca.parser/tosca-types/added-types/", 
			nodes, capabilities, relationships, policies);
	customTypesMap.put("tosca_definitions_version", "tosca_simple_yaml_1_0");
	customTypesMap.put("description",
			"This TOSCA definitions document contains the custom types definitions as expressed in the TOSCA specification document. It is composed by the files in the directory custom-types");
	customTypesMap.put("node_types", nodes);
	customTypesMap.put("capability_types", capabilities);
	customTypesMap.put("relationship_types", relationships);
	customTypesMap.put("policy_types", policies);
	YamlWriter writerNodes = new YamlWriter(new FileWriter(
			"C:/Users/schallit/workspace-tosca2/plugins/org.eclipse.cmf.occi.tosca.parser/tosca-types/custom-types.yml"));
	writerNodes.write(customTypesMap);
	writerNodes.close();
	return customTypesMap;
}
 
开发者ID:occiware,项目名称:TOSCA-Studio,代码行数:24,代码来源:Main.java

示例4: saveConfig

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
/**
 * This method writes the configuration file to disk.  The current
 * implementation omits the user/password information.
 * @param config to be persisted
 */
private void saveConfig(final Config config) {
    final File configFile = config.getWriteConfig();

    // Write config to file
    if (configFile != null) {
        try {
            final YamlWriter writer = new YamlWriter(new FileWriter(configFile));
            logger.debug("YAML output is ({})", config.getMap().toString());
            writer.write(config.getMap());
            writer.close();
            logger.info("Saved configuration to: {}", configFile.getPath());

        } catch (final IOException e) {
            throw new RuntimeException("Unable to write configuration file due to: " + e.getMessage(), e);
        }
    }
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:23,代码来源:ArgParser.java

示例5: convertToYaml

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
/**
 * Convert {@link org.opentosca.yamlconverter.yamlmodel.yaml.element.YAMLElement} to a string using
 * {@link com.esotericsoftware.yamlbeans.YamlWriter}. Makes use of {@link #adjustConfig(com.esotericsoftware.yamlbeans.YamlConfig)} to
 * set properties for {@link com.esotericsoftware.yamlbeans.YamlConfig}.
 *
 * @param yamlRoot child element of {@link org.opentosca.yamlconverter.yamlmodel.yaml.element.YAMLElement} containing values
 * @return {@code yamlRoot} as YAML string
 * @throws ConverterException
 */
@Override
public String convertToYaml(YAMLElement yamlRoot) throws ConverterException {
	if (yamlRoot == null) {
		throw new IllegalArgumentException("Root element may not be null!");
	}
	final Writer output = new StringWriter();
	final YamlWriter writer = new YamlWriter(output);
	adjustConfig(writer.getConfig());
	try {
		writer.write(yamlRoot);
		writer.close();
	} catch (final YamlException e) {
		throw new ConverterException(e);
	}
	return output.toString();
}
 
开发者ID:CloudCycle2,项目名称:YAML_Transformer,代码行数:26,代码来源:YamlBeansConverter.java

示例6: saveConfig

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
public static void saveConfig() {
	try {
		YamlWriter writer = new YamlWriter(new FileWriter("config.yml"));
		
		Map map = new HashMap();
		map.put("BindAddress", BIND_ADDRESS);
		map.put("BindPort", BIND_PORT);
		map.put("KickMessage", KICK_MESSAGE);
		map.put("Version", VERSION_NAME);
		map.put("Motd", MOTD);
		map.put("MultilineMotd", MULTILINE_MOTD);
		
		writer.write(map);
		writer.close();
	} catch (Exception e) {
		System.err.println("Error while saving the Config: " + e.getMessage());
		e.printStackTrace();
	}
}
 
开发者ID:Howaner,项目名称:BukkitMaintenance,代码行数:20,代码来源:Config.java

示例7: saveToFile

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
public static void saveToFile(String filename, RefPanelList panels)
		throws IOException {

	YamlWriter writer = new YamlWriter(new FileWriter(filename));
	writer.getConfig().setClassTag(
			"genepi.minicloudmac.hadoop.util.RefPanelList",
			RefPanelList.class);
	writer.getConfig().setPropertyElementType(RefPanelList.class, "panels",
			RefPanel.class);
	writer.write(panels);
	writer.close();

}
 
开发者ID:genepi,项目名称:imputationserver,代码行数:14,代码来源:RefPanelList.java

示例8: write

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
public void write(File outYaml) throws IOException {

		Map<String, Object> asciigenome_history= new HashMap<String, Object>();
		
		// List of commands
		List<String>lastCommands= new ArrayList<String>();
		int max_cmds= MAX_CMDS;
		for(String cmd : this.getCommands()){
			if(max_cmds == 0){
				break;
			}
			max_cmds--;
			lastCommands.add(cmd.trim());
		}
		asciigenome_history.put("commands", lastCommands);
		
		// List of files
		List<String>lastFiles= this.getFiles();
		lastFiles= lastFiles.subList(Math.max(0, lastFiles.size() - MAX_FILES), lastFiles.size());
		// Convert ArrayList#subList to List so the yaml file does show an odd data type.
		asciigenome_history.put("files", new ArrayList<String>(lastFiles));
		
		// Positions
		List<String> lastPos= this.getPositions();
		asciigenome_history.put("positions", lastPos);

		// Reference
		List<String> ref= this.getReference();
		if(ref != null && ref.size() > 0 && ref.get(0) != null && ! ref.get(0).trim().isEmpty()){
			asciigenome_history.put("reference", new ArrayList<String>(ref));
		}
		
		// Write yaml
		YamlWriter writer = new YamlWriter(new FileWriter(outYaml));
	    writer.write(asciigenome_history);
	    writer.close();

	}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:39,代码来源:ASCIIGenomeHistory.java

示例9: write

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
public void write(ExperimentConfiguration conf, String filename) throws IOException {
	YamlWriter writer = new YamlWriter(new FileWriter(filename));
	
	configure(writer.getConfig());
	
	try {
		writer.write(conf);
	} catch (YamlException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	writer.close();
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:14,代码来源:ExperimentConfigurationSerializer.java

示例10: serializeYAML

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
/**
 * Serializes the given map to a yaml string
 *
 * @param getterMap to serialize
 * @return the yaml string, or <code>null</code> if an exception occurred.
 */
private String serializeYAML(Map<String, Object> getterMap) {
	final Writer output = new StringWriter();
	final YamlWriter writer = new YamlWriter(output);
	try {
		writer.write(getterMap);
		writer.close();
	} catch (final YamlException e) {
		return null;
	}
	return output.toString();
}
 
开发者ID:CloudCycle2,项目名称:YAML_Transformer,代码行数:18,代码来源:PropertiesParserUtil.java

示例11: writeDocument

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
private String writeDocument(YamlDocument yaml) throws YamlException {
	StringWriter writer = new StringWriter();
	YamlConfig config = new YamlConfig();
	config.writeConfig.setExplicitFirstDocument(yaml.getTag()!=null);
	config.writeConfig.setWriteClassname(WriteClassName.NEVER);
	config.writeConfig.setAutoAnchor(false);
	YamlWriter yamlWriter = new YamlWriter(writer, config);
	yamlWriter.write(yaml);
	yamlWriter.close();	
	return writer.toString();
}
 
开发者ID:EsotericSoftware,项目名称:yamlbeans,代码行数:12,代码来源:YamlDocumentTest.java

示例12: writeBpmManifest

import com.esotericsoftware.yamlbeans.YamlWriter; //导入方法依赖的package包/类
protected void writeBpmManifest(Map<String, PluginInfo> manifest) throws Exception {
	File manifestFile = new File(BukkitPackageManager.plugins, "bpm.yml");
	YamlWriter writer = new YamlWriter(new FileWriter(manifestFile));
	writer.write(manifest);
	writer.close();
}
 
开发者ID:MegaApuTurkUltra,项目名称:bpm,代码行数:7,代码来源:Plugin.java


注:本文中的com.esotericsoftware.yamlbeans.YamlWriter.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。