org.apache.felix.utils.properties.Properties.store()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(119)

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

Properties.store介绍

[英]Store a properties into a output stream, preserving comments, special character, etc. This method is mainly to be compatible with the java.util.Properties class.
[中]将属性存储到输出流中,保留注释、特殊字符等。这种方法主要是为了与java兼容。util。属性类。

代码示例

代码示例来源:origin: org.apache.felix/org.apache.felix.fileinstall

/**
 * Store a properties into a output stream, preserving comments, special character, etc.
 * This method is mainly to be compatible with the java.util.Properties class.
 *
 * @param os an output stream.
 * @param comment this parameter is ignored as this Properties
 * @throws IOException If storing fails
 */
public void store(OutputStream os, String comment) throws IOException {
  storage.store(os, comment);
}

代码示例来源:origin: apache/felix

/**
 * Store a properties into a output stream, preserving comments, special character, etc.
 * This method is mainly to be compatible with the java.util.Properties class.
 *
 * @param os an output stream.
 * @param comment this parameter is ignored as this Properties
 * @throws IOException If storing fails
 */
public void store(OutputStream os, String comment) throws IOException {
  storage.store(os, comment);
}

代码示例来源:origin: org.apache.felix/org.apache.felix.utils

/**
 * Store a properties into a output stream, preserving comments, special character, etc.
 * This method is mainly to be compatible with the java.util.Properties class.
 *
 * @param os an output stream.
 * @param comment this parameter is ignored as this Properties
 * @throws IOException If storing fails
 */
public void store(OutputStream os, String comment) throws IOException {
  storage.store(os, comment);
}

代码示例来源:origin: jboss-fuse/fabric8

public static byte[] toBytes(Properties source) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
    source.store(baos, null);
  } catch (IOException ex) {
    throw new IllegalArgumentException("Cannot store properties", ex);
  }
  return baos.toByteArray();
}

代码示例来源:origin: apache/karaf

@Override
public void setName(String name) {
  try {
    String karafEtc = bundleContext.getProperty("karaf.etc");
    File etcDir = new File(karafEtc);
    File syspropsFile = new File(etcDir, "system.properties");
    FileInputStream fis = new FileInputStream(syspropsFile);
    Properties props = new Properties();
    props.load(fis);
    fis.close();
    props.setProperty("karaf.name", name);
    FileOutputStream fos = new FileOutputStream(syspropsFile);
    props.store(fos, "");
    fos.close();
  } catch (Exception e) {
    throw new RuntimeException(e.getMessage(), e);
  }
}

代码示例来源:origin: org.apache.karaf.system/org.apache.karaf.system.core

@Override
public void setName(String name) {
  try {
    String karafEtc = bundleContext.getProperty("karaf.etc");
    File etcDir = new File(karafEtc);
    File syspropsFile = new File(etcDir, "system.properties");
    FileInputStream fis = new FileInputStream(syspropsFile);
    Properties props = new Properties();
    props.load(fis);
    fis.close();
    props.setProperty("karaf.name", name);
    FileOutputStream fos = new FileOutputStream(syspropsFile);
    props.store(fos, "");
    fos.close();
  } catch (Exception e) {
    throw new RuntimeException(e.getMessage(), e);
  }
}

代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.osgi

protected Object doExecute() throws Exception {
  if (name == null) {
    System.out.println(bundleContext.getProperty("karaf.name"));
  } else {
    try {
      String karafEtc = bundleContext.getProperty("karaf.etc");
      File syspropsFile = new File(karafEtc, "system.properties");
      FileInputStream fis = new FileInputStream(syspropsFile);
      Properties props = new Properties();
      props.load(fis);
      fis.close();
      props.setProperty("karaf.name", name);
      FileOutputStream fos = new FileOutputStream(syspropsFile);
      props.store(fos, "");
      fos.close();
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    System.out.println("Instance name changed to " + name + ". Restart needed for this to take effect.");
  }
  return null;
}

代码示例来源:origin: io.fabric8.patch/patch-management

result.store(baos, null);

代码示例来源:origin: jboss-fuse/fabric8

result.store(baos, null);

相关文章