Java Code Examples for java.util.Properties.storeToXML()

The following are Jave code examples for showing how to use storeToXML() of the java.util.Properties class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: oscm   File: PluginServiceFactoryTest.java   View Source Code Vote up 6 votes
@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);
}
 
Example 2
Project: incubator-netbeans   File: ProfilerStorageProvider.java   View Source Code Vote up 5 votes
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();
        }
    }
}
 
Example 3
Project: joanne   File: XMLManager.java   View Source Code Vote up 5 votes
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;
}
 
Example 4
Project: oscm-app   File: ServiceInstance.java   View Source Code Vote up 5 votes
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;
}
 
Example 5
Project: oscm-app   File: Operation.java   View Source Code Vote up 5 votes
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;
}
 
Example 6
Project: neoscada   File: DataStoreAccesor.java   View Source Code Vote up 5 votes
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 );
}
 
Example 7
Project: neoscada   File: StorageHelper.java   View Source Code Vote up 5 votes
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 );
}
 
Example 8
Project: oscm   File: ServiceInstance.java   View Source Code Vote up 5 votes
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;
}
 
Example 9
Project: oscm   File: Operation.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: oscm   File: BillingAdapterAssembler.java   View Source Code Vote up 5 votes
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;
}
 
Example 11
Project: ramus   File: RolesView.java   View Source Code Vote up 5 votes
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();
    }
}
 
Example 12
Project: ramus   File: AbstractEngine.java   View Source Code Vote up 5 votes
@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);
    }

}
 
Example 13
Project: jdk8u-jdk   File: LoadAndStoreXMLWithDefaults.java   View Source Code Vote up 4 votes
@Override
public String writeToXML(Properties p) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    p.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 14
Project: openjdk-jdk10   File: LoadAndStoreXMLWithDefaults.java   View Source Code Vote up 4 votes
static String writeToXML(Properties props) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    props.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 15
Project: util   File: DefaultPropertiesPersister.java   View Source Code Vote up 4 votes
@Override
public void storeToXml(Properties props, OutputStream os, String header) throws IOException {
	props.storeToXML(os, header);
}
 
Example 16
Project: util   File: DefaultPropertiesPersister.java   View Source Code Vote up 4 votes
@Override
public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException {
	props.storeToXML(os, header, encoding);
}