net.roboconf.core.utils.Utils.updateProperties()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中net.roboconf.core.utils.Utils.updateProperties()方法的一些代码示例,展示了Utils.updateProperties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.updateProperties()方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:updateProperties

Utils.updateProperties介绍

[英]Updates string properties.
[中]更新字符串属性。

代码示例

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testUpdateProperties() throws Exception {
  File before = TestUtils.findTestFile( "/properties/before.properties" );
  String beforeTxt = Utils.readFileContent( before );
  File after = TestUtils.findTestFile( "/properties/after.properties" );
  String afterTxt = Utils.readFileContent( after );
  // One way
  Map<String,String> keyToNewValue = new HashMap<> ();
  keyToNewValue.put( "application-name", "app" );
  keyToNewValue.put( "scoped-instance-path", "/vm" );
  keyToNewValue.put( "parameters", "file:/something" );
  keyToNewValue.put( "messaging-type", "http" );
  String out = Utils.updateProperties( beforeTxt, keyToNewValue );
  Assert.assertEquals( afterTxt, out );
  // Other way
  keyToNewValue.clear();
  keyToNewValue.put( "application-name", "" );
  keyToNewValue.put( "scoped-instance-path", "" );
  keyToNewValue.put( "paraMeters", "" );
  keyToNewValue.put( "messaging-type", "idle" );
  out = Utils.updateProperties( afterTxt, keyToNewValue );
  Assert.assertEquals( beforeTxt, out );
}

代码示例来源:origin: net.roboconf/roboconf-agent

try {
  String content = Utils.readFileContent( agentConfigFile );
  content = Utils.updateProperties( content, keyToNewValue );
  Utils.writeStringInto( content, agentConfigFile );

相关文章

微信公众号

最新文章

更多