本文整理匯總了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);
}