本文整理汇总了Java中java.util.Properties.storeToXML方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.storeToXML方法的具体用法?Java Properties.storeToXML怎么用?Java Properties.storeToXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Properties
的用法示例。
在下文中一共展示了Properties.storeToXML方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnectionProperties
import java.util.Properties; //导入方法依赖的package包/类
@Test
public void getConnectionProperties() throws Exception {
// given
BillingAdapter ba = spy(new BillingAdapter());
Properties props = createConnectionProperties("FileAdapter");
try (ByteArrayOutputStream stream = new ByteArrayOutputStream();) {
props.storeToXML(stream, null, StandardCharsets.UTF_8.toString());
ba.setConnectionProperties(stream.toString());
}
// when
Properties p = PluginServiceFactory.getConnectionProperties(ba);
// then
assertEquals(createConnectionProperties("FileAdapter"), p);
}
示例2: saveProperties
import java.util.Properties; //导入方法依赖的package包/类
protected void saveProperties(Properties properties, FileObject storage) throws IOException {
synchronized (this) {
OutputStream os = storage.getOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(os);
try {
properties.storeToXML(bos, ""); // NOI18N
} finally {
if (bos != null) bos.close();
}
}
}
示例3: saveFoldersList
import java.util.Properties; //导入方法依赖的package包/类
public boolean saveFoldersList(ArrayList<String> list) throws FileNotFoundException, IOException{
Properties p = getFoldersList();
String pa = "";
if(new File(pa).isFile()){
pa = new File(pa).getParent();
}
FileOutputStream f = new FileOutputStream(new File(PATH));
if(!p.containsKey(pa)){
p.setProperty(new File(pa).getAbsolutePath(),new File(pa).getName());
}else{
return false;
}
p.storeToXML(f,null);
return true;
}
示例4: convertPropertiesToXML
import java.util.Properties; //导入方法依赖的package包/类
String convertPropertiesToXML(Properties properties)
throws RuntimeException {
String xmlString;
try (OutputStream out = new ByteArrayOutputStream()) {
properties.storeToXML(out, null, "UTF-8");
xmlString = out.toString();
} catch (IOException e) {
throw new RuntimeException();
}
return xmlString;
}
示例5: convertPropertiesToXML
import java.util.Properties; //导入方法依赖的package包/类
String convertPropertiesToXML(Properties properties) {
String xmlString = null;
try (OutputStream out = new ByteArrayOutputStream()) {
properties.storeToXML(out, null, "UTF-8");
xmlString = out.toString();
} catch (IOException e) {
LOGGER.logError(Log4jLogger.SYSTEM_LOG, e,
LogMessageIdentifier.ERROR);
}
return xmlString;
}
示例6: create
import java.util.Properties; //导入方法依赖的package包/类
public static DataStoreAccesor create ( final File basePath, final long time, final TimeUnit unit, final int count, final DataFilePool pool ) throws Exception
{
if ( basePath.exists () )
{
throw new IllegalArgumentException ( String.format ( "'%s' must not exists", basePath ) );
}
if ( !basePath.getParentFile ().isDirectory () )
{
throw new IllegalArgumentException ( String.format ( "Parent directory '%s' must exists and must be a directory", basePath.getParentFile () ) );
}
if ( !basePath.mkdir () )
{
throw new IllegalArgumentException ( String.format ( "Unable to create directory %s", basePath ) );
}
final Properties p = new Properties ();
p.put ( "time", "" + time );
p.put ( "unit", unit.name () );
p.put ( "count", "" + count );
p.put ( "version", "1" );
try
{
p.storeToXML ( new FileOutputStream ( new File ( basePath, "settings.xml" ) ), "Eclipse SCADA HDS Settings" );
}
catch ( final Exception e )
{
// try to delete directory
basePath.delete ();
throw new IllegalStateException ( e );
}
return new DataStoreAccesor ( basePath, pool );
}
示例7: create
import java.util.Properties; //导入方法依赖的package包/类
public static void create ( final String id, final File file, final StorageConfiguration configuration, final DataFilePool pool ) throws Exception
{
file.mkdir ();
final Properties p = new Properties ();
p.put ( "id", id );
p.storeToXML ( new FileOutputStream ( new File ( file, "settings.xml" ) ), "Eclipse SCADA HD HDS Storage Settings" );
DataStoreAccesor.create ( new File ( file, "native" ), configuration.getTimeSlice (), TimeUnit.MILLISECONDS, configuration.getCount (), pool );
}
示例8: convertPropertiesToXML
import java.util.Properties; //导入方法依赖的package包/类
static String convertPropertiesToXML(Properties properties)
throws IOException {
if (properties != null) {
String xmlString;
try (OutputStream out = new ByteArrayOutputStream()) {
properties.storeToXML(out, null, "UTF-8");
xmlString = out.toString();
}
return xmlString;
}
return null;
}
示例9: setProperty
import java.util.Properties; //导入方法依赖的package包/类
public void setProperty(final String key, final String value) {
Properties properties = getProperties();
properties.setProperty(key, value);
final OutputStream out = setNamedData(PROPERTIES);
try {
properties.storeToXML(out, "");
out.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
示例10: setProperties
import java.util.Properties; //导入方法依赖的package包/类
@Override
public void setProperties(String path, Properties properties) {
OutputStream out = getOutputStream(path);
try {
properties.storeToXML(out, "Path: " + path);
out.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例11: writeToXML
import java.util.Properties; //导入方法依赖的package包/类
@Override
public String writeToXML(Properties p) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
p.storeToXML(baos, "Test 8016344");
return baos.toString();
}
示例12: writeToXML
import java.util.Properties; //导入方法依赖的package包/类
static String writeToXML(Properties props) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
props.storeToXML(baos, "Test 8016344");
return baos.toString();
}
示例13: storeToXml
import java.util.Properties; //导入方法依赖的package包/类
@Override
public void storeToXml(Properties props, OutputStream os, String header) throws IOException {
props.storeToXML(os, header);
}