本文整理汇总了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();
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}