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

The following examples show how to use java.util.Properties#storeToXML() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DropboxSyncManager.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
private void saveCredentials () throws IOException
{
	
	if (mSession != null && mSession.isLinked()
			&& mSession.getOAuth2AccessToken() != null)
	{
		
        mStoredAccessToken = mSession.getOAuth2AccessToken();
        
        Properties props = new Properties();
        props.setProperty("dbtoken", mStoredAccessToken);
        
        info.guardianproject.iocipher.File fileProps = new info.guardianproject.iocipher.File("/dropbox.properties");
        info.guardianproject.iocipher.FileOutputStream fos = new info.guardianproject.iocipher.FileOutputStream(fileProps);
        props.storeToXML(fos,"");
        fos.close();
        
	}
	else
	{
		Log.d("Dropbox","no valid dropbox session / not linked");
        
	}
}
 
Example 2
Source File: Properties2XML.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
	Properties props = new Properties();
   	props.setProperty("email.support", "[email protected]");
   	props.setProperty("email.password", "*********");
   	props.setProperty("email.host", "smtp.163.com");
   	props.setProperty("email.port", "25");
   	
   	OutputStream os = new FileOutputStream("target/email-config.xml");
   	props.storeToXML(os, "email config","UTF-8");
   	 
   	System.out.println("Done");
}
 
Example 3
Source File: ProfilerStorageProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: AutoSummENGGui.java    From Ngram-Graphs with Apache License 2.0 5 votes vote down vote up
/** Save GUI settings in file. */
private void saveSettings() {
    Properties pOut = new Properties();
    // Dirs
    pOut.setProperty("ModelDir", ModelsRootDirEdt.getText());
    pOut.setProperty("SummaryDir", SummariesRootDirEdt.getText());
    pOut.setProperty("OutputFile", OutputFileEdt.getText());
    
    // Global settings
    pOut.setProperty("Threads", ThreadCntEdt.getValue().toString());
    pOut.setProperty("Silent", String.valueOf(SilentChk.isSelected()));
    pOut.setProperty("ShowProgress", String.valueOf(ProgressChk.isSelected()));
    pOut.setProperty("DoWord", String.valueOf(DoWordChk.isSelected()));
    pOut.setProperty("DoChar", String.valueOf(DoCharChk.isSelected()));
    pOut.setProperty("Use", OccurencesChk.isSelected() ? "Occurences" : "Distros");
    // Char settings
    pOut.setProperty("CharMin", String.valueOf(CharMinEdt.getValue()));
    pOut.setProperty("CharMax", String.valueOf(CharMaxEdt.getValue()));
    pOut.setProperty("CharDist", String.valueOf(CharDistEdt.getValue()));
    // Word settings
    pOut.setProperty("WordMin", String.valueOf(WordMinEdt.getValue()));
    pOut.setProperty("WordMax", String.valueOf(WordMaxEdt.getValue()));
    pOut.setProperty("WordDist", String.valueOf(WordDistEdt.getValue()));
    
    // Save
    try {
        FileOutputStream fsOut = new FileOutputStream("AutoSummENGGUI.properties");
        pOut.storeToXML(fsOut, "");
        fsOut.flush();
        fsOut.close();
    }
    catch (IOException ioe) {
        ioe.printStackTrace(System.err);
    }

}
 
Example 5
Source File: Configuration.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Save the configuration.
 * @return true if the save was successful.
 */
public boolean save() {
	try {
		Properties props = new Properties();
		try (FileOutputStream fout = new FileOutputStream(fileName)) {
			saveProperties(props);
			props.storeToXML(fout, "Open Imperium Galactica Configuration");
		}
		isNew = false;
		return true;
	} catch (IOException ex) {
		Exceptions.add(ex);
		return false;
	}
}
 
Example 6
Source File: TestPackageInstall.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
/**
 * Tests if installing a package with a 0-mtime entry works with java9.
 * see http://bugs.java.com/view_bug.do?bug_id=JDK-8184940
 */
@Test
public void testPackageInstallWith0MtimeZipEntry() throws IOException, RepositoryException, NoSuchFieldException, IllegalAccessException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ZipOutputStream zout = new ZipOutputStream(out);
    Properties p = new Properties();
    p.setProperty("name", TMP_PACKAGE_ID.getName());
    p.setProperty("group", TMP_PACKAGE_ID.getGroup());
    p.setProperty("version", TMP_PACKAGE_ID.getVersionString());
    ZipEntry e = new ZipEntry("META-INF/vault/properties.xml");

    Field field = ZipEntry.class.getDeclaredField("xdostime");
    field.setAccessible(true);
    field.setLong(e, 0);
    zout.putNextEntry(e);
    p.storeToXML(zout, "", "utf-8");
    zout.closeEntry();

    zout.putNextEntry(new ZipEntry("jcr_root/"));
    zout.closeEntry();

    zout.close();
    out.close();

    JcrPackage pack = packMgr.upload(new ByteArrayInputStream(out.toByteArray()), true);
    assertEquals("packageid", TMP_PACKAGE_ID, pack.getDefinition().getId());
}
 
Example 7
Source File: ControllerForm.java    From AndroidDesignPreview with Apache License 2.0 5 votes vote down vote up
private void trySaveFrameConfig() {
    try {
        Properties props = new Properties();
        props.setProperty("x", String.valueOf(frame.getX()));
        props.setProperty("y", String.valueOf(frame.getY()));
        props.storeToXML(new FileOutputStream(
                new File(Util.getCacheDirectory(), "config.xml")), null);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 8
Source File: PropertyFilesUtil.java    From journaldev with MIT License 5 votes vote down vote up
/**
 * This method writes Property files into file system in property file
 * and xml format
 * @param fileName
 * @throws IOException
 */
private static void writePropertyFile(String propertyFileName, String xmlFileName) throws IOException {
	System.out.println("Start of writePropertyFile");
	Properties prop = new Properties();
	prop.setProperty("db.host", "localhost");
	prop.setProperty("db.user", "user");
	prop.setProperty("db.pwd", "password");
	prop.store(new FileWriter(propertyFileName), "DB Config file");
	System.out.println(propertyFileName + " written successfully");
	prop.storeToXML(new FileOutputStream(xmlFileName), "DB Config XML file");
	System.out.println(xmlFileName + " written successfully");
	System.out.println("End of writePropertyFile");
}
 
Example 9
Source File: RolesView.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
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 10
Source File: BillingAdapterAssembler.java    From development with Apache License 2.0 5 votes vote down vote up
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
Source File: LoadAndStoreXMLWithDefaults.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String writeToXML(Properties p) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    p.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 12
Source File: DefaultPropertiesPersister.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void storeToXml(Properties props, OutputStream os, String header) throws IOException {
	props.storeToXML(os, header);
}
 
Example 13
Source File: LoadAndStoreXMLWithDefaults.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String writeToXML(Properties p) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    p.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 14
Source File: LoadAndStoreXMLWithDefaults.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static String writeToXML(Properties props) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    props.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 15
Source File: LoadAndStoreXMLWithDefaults.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String writeToXML(Properties p) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    p.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 16
Source File: LoadAndStoreXMLWithDefaults.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String writeToXML(Properties p) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    p.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 17
Source File: DefaultPropertiesPersister.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException {
	props.storeToXML(os, header, encoding);
}
 
Example 18
Source File: DefaultPropertiesPersister.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException {
	props.storeToXML(os, header, encoding);
}
 
Example 19
Source File: LoadAndStoreXMLWithDefaults.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String writeToXML(Properties p) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    p.storeToXML(baos, "Test 8016344");
    return baos.toString();
}
 
Example 20
Source File: DefaultPropertiesPersister.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException {
	props.storeToXML(os, header, encoding);
}