List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:net.mybox.mybox.ServerSetup.java
/** * Save the configuration file to the filesystem * @return true if the file saved//from w w w. j a v a 2 s . c o m */ private boolean saveConfig() { // TODO: handle existing file Properties config = new Properties(); config.setProperty("port", Integer.toString(port)); config.setProperty("maxClients", Integer.toString(maxClients)); config.setProperty("defaultQuota", Integer.toString(defaultQuota)); config.setProperty("baseDataDir", baseDataDir); config.setProperty("accountsDbFile", accountsDbFile); try { FileOutputStream MyOutputStream = new FileOutputStream(configFile); config.store(MyOutputStream, "Mybox server configuration file"); } catch (Exception e) { Server.printWarning(e.getMessage()); return false; } return true; }
From source file:com.isencia.passerelle.runtime.repos.impl.filesystem.FlowRepositoryServiceImpl.java
/** * @param flowCode//from w ww . j a va 2 s .c o m * @param flowMetaDataProps * @throws IOException */ private void writeMetaData(String flowCode, Properties flowMetaDataProps) throws IOException { File flowRootFolder = new File(rootFolder, flowCode); File metaDataFile2 = new File(flowRootFolder, ".metadata"); Writer metaDataWriter = new FileWriter(metaDataFile2); try { flowMetaDataProps.store(metaDataWriter, flowCode); } finally { metaDataWriter.close(); } }
From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.AbstractPackagingMojo.java
/** * <p>// w ww . ja v a 2 s. c om * This saves a java.util.Properties to a file.<br /> * * It is possible to add a comment at the beginning of the file. * </p> * * @param outputFile, the File where to output the Properties * @param properties, the Properties to save * @param propertiesComment, the comment to add at the beginning of the file * @param success, the success message * @param failure, the failure message * @throws MojoExecutionException */ protected void savePropertiesToFile(File outputFile, Properties properties, String propertiesComment, String success, String failure) throws MojoExecutionException { OutputStream outputStream = null; try { outputFile.getParentFile().mkdirs(); outputStream = new FileOutputStream(outputFile); properties.store(outputStream, propertiesComment); if (filterProperties) { getLog().debug("Filtering properties files"); File tmpDir = new File(outputFile.getParentFile(), "tmp"); tmpDir.mkdir(); List<Resource> resources = new ArrayList<Resource>(); Resource r = new Resource(); r.setDirectory(outputFile.getParentFile().getAbsolutePath()); r.addInclude("*.properties"); r.setFiltering(true); resources.add(r); ArrayList<Object> filters = new ArrayList<Object>(); List<String> nonFilteredFileExtensions = new ArrayList<String>(); MavenResourcesExecution mre = new MavenResourcesExecution(resources, tmpDir, this.getProject(), this.sourceEncoding, filters, nonFilteredFileExtensions, session); mavenResourcesFiltering.filterResources(mre); FileUtils.copyDirectory(tmpDir, outputFile.getParentFile()); FileUtils.deleteDirectory(tmpDir); } getLog().info(success + " '" + outputFile + "'"); } catch (Exception e) { throw new MojoExecutionException(failure + " '" + outputFile + "'", e); } finally { try { outputStream.close(); } catch (Exception e) { } } }
From source file:com.smartitengineering.util.bean.spring.PropertiesLocatorConfigurerTest.java
private void initPaths(StringBuilder paths, boolean createBean3Rsrc) { String path = "./target/a/"; File dir = new File(path); if (!dir.exists()) { dir.mkdirs();//from w w w .ja v a2 s . com } Properties properties = new Properties(); properties.setProperty("testbean.default", "default 2"); File fileCurrentDir = new File(dir, "test-config-custom.properties"); try { FileOutputStream fos = new FileOutputStream(fileCurrentDir); properties.store(fos, ""); fos.close(); } catch (IOException ex) { fail(ex.getMessage()); } paths.append(path); path = "./target/b/"; dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } properties = new Properties(); properties.setProperty("testbean.cp", "cp 2"); fileCurrentDir = new File(dir, "test-config-custom.properties"); try { FileOutputStream fos = new FileOutputStream(fileCurrentDir); properties.store(fos, ""); fos.close(); } catch (IOException ex) { fail(ex.getMessage()); } paths.append(','); paths.append(path); path = "./target/c/"; dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } properties = new Properties(); properties.setProperty("testbean.current_dir", "current dir"); fileCurrentDir = new File(dir, "test-config-custom.properties"); try { FileOutputStream fos = new FileOutputStream(fileCurrentDir); properties.store(fos, ""); fos.close(); } catch (IOException ex) { fail(ex.getMessage()); } paths.append(','); paths.append(path); path = "./target/d/"; dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } properties = new Properties(); properties.setProperty("testbean.current_dir", "current dir 2"); properties.setProperty("testbean.user_home", "user home dir 2"); fileCurrentDir = new File(dir, "test-config-custom.properties"); try { FileOutputStream fos = new FileOutputStream(fileCurrentDir); properties.store(fos, ""); fos.close(); } catch (IOException ex) { fail(ex.getMessage()); } if (createBean3Rsrc) { properties = new Properties(); properties.setProperty("testbean.current_dir", "current dir 3"); properties.setProperty("testbean.user_home", "user home dir 3"); dir = new File(dir, "custom-context/custom-path/"); dir.mkdirs(); fileCurrentDir = new File(dir, "test-config.properties"); try { FileOutputStream fos = new FileOutputStream(fileCurrentDir); properties.store(fos, ""); fos.close(); } catch (IOException ex) { fail(ex.getMessage()); } } paths.append(','); paths.append(path); }
From source file:cpcc.vvrte.services.VirtualVehicleMigratorImpl.java
/** * @param virtualVehicle the virtual vehicle. * @param os the output stream to write to. * @param chunkNumber the chunk number./* ww w . j a v a2 s . c om*/ * @throws IOException thrown in case of errors. */ private void writeVirtualVehicleProperties(VirtualVehicle virtualVehicle, ArchiveOutputStream os, int chunkNumber, boolean lastChunk) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Properties virtualVehicleProps = fillVirtualVehicleProps(virtualVehicle, lastChunk); virtualVehicleProps.store(baos, "Virtual Vehicle Properties"); baos.close(); byte[] propBytes = baos.toByteArray(); TarArchiveEntry entry = new TarArchiveEntry(DATA_VV_PROPERTIES); entry.setModTime(new Date()); entry.setSize(propBytes.length); entry.setIds(0, chunkNumber); entry.setNames("vvrte", "cpcc"); os.putArchiveEntry(entry); os.write(propBytes); os.closeArchiveEntry(); }
From source file:com.liferay.ide.project.core.tests.ProjectCoreBase.java
private void persistAppServerProperties() throws FileNotFoundException, IOException, ConfigurationException { Properties initProps = new Properties(); initProps.put("app.server.type", "tomcat"); initProps.put("app.server.tomcat.dir", getLiferayRuntimeDir().toPortableString()); initProps.put("app.server.tomcat.deploy.dir", getLiferayRuntimeDir().append("webapps").toPortableString()); initProps.put("app.server.tomcat.lib.global.dir", getLiferayRuntimeDir().append("lib/ext").toPortableString()); initProps.put("app.server.parent.dir", getLiferayRuntimeDir().removeLastSegments(1).toPortableString()); initProps.put("app.server.tomcat.portal.dir", getLiferayRuntimeDir().append("webapps/ROOT").toPortableString()); IPath loc = getLiferayPluginsSdkDir(); String userName = System.getProperty("user.name"); //$NON-NLS-1$ File userBuildFile = loc.append("build." + userName + ".properties").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ try (FileOutputStream fileOutput = new FileOutputStream(userBuildFile)) { if (userBuildFile.exists()) { PropertiesConfiguration propsConfig = new PropertiesConfiguration(userBuildFile); for (Object key : initProps.keySet()) { propsConfig.setProperty((String) key, initProps.get(key)); }//from w w w . jav a 2 s. c om propsConfig.setHeader(""); propsConfig.save(fileOutput); } else { Properties props = new Properties(); props.putAll(initProps); props.store(fileOutput, StringPool.EMPTY); } } }
From source file:com.googlecode.fascinator.storage.jclouds.BlobStorePayload.java
private void writePayloadMetadata(Map<String, String> userMetadata) throws StorageException { Properties metadata = new Properties(); for (String key : userMetadata.keySet()) { metadata.setProperty(key, userMetadata.get(key)); }/*from ww w.jav a2 s.co m*/ BlobStore blobStore = BlobStoreClient.getClient(); ByteArrayOutputStream output = new ByteArrayOutputStream(); try { metadata.store(output, null); } catch (IOException e) { throw new StorageException("Failed to write payload metadata", e); } InputStream input = new ByteArrayInputStream(output.toByteArray()); Blob metadataBlob = blobStore.blobBuilder(blob.getMetadata().getName() + METADATA_SUFFIX).build(); metadataBlob.setPayload(input); blobStore.putBlob(BlobStoreClient.getContainerName(), metadataBlob); }
From source file:org.globus.security.provider.TestPEMFileBasedKeyStore.java
private InputStream getProperties(Properties properties) throws Exception { ByteArrayOutputStream stream = null; ByteArrayInputStream ins = null; try {/*from www. j a v a 2s . com*/ stream = new ByteArrayOutputStream(); properties.store(stream, "Test Properties"); // load all the CA files ins = new ByteArrayInputStream(stream.toByteArray()); } finally { if (stream != null) { stream.close(); } } return ins; }
From source file:com.github.formatter.JSBeautifier.java
private void storeFileHashCache(Properties props) { File cacheFile = new File(targetDirectory, CACHE_PROPERTIES_FILENAME); try {/*from w w w . jav a2 s . c o m*/ OutputStream out = new BufferedOutputStream(new FileOutputStream(cacheFile)); props.store(out, null); } catch (FileNotFoundException e) { getLog().warn("Cannot store file hash cache properties file", e); } catch (IOException e) { getLog().warn("Cannot store file hash cache properties file", e); } }
From source file:com.bladecoder.engineeditor.ui.PackageDialog.java
private String packageAdv() throws IOException { String msg = "Package generated SUCCESSFULLY"; String projectName = getAppName(); if (projectName == null) Ctx.project.getProjectDir().getName(); String versionParam = "-Pversion=" + version.getText() + " "; Ctx.project.getProjectConfig().setProperty(Config.VERSION_PROP, version.getText()); if (arch.getText().equals("desktop")) { String jarDir = Ctx.project.getProjectDir().getAbsolutePath() + "/desktop/build/libs/"; String jarName = projectName + "-desktop-" + version.getText() + ".jar"; msg = genDesktopJar(projectName, versionParam, jarDir, jarName); if (type.getText().equals(TYPES[0])) { // BUNDLE JRE if (os.getText().equals("linux64")) { packr(Platform.linux64, linux64JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText());/*from w w w .j av a 2 s. c om*/ } else if (os.getText().equals("linux32")) { packr(Platform.linux32, linux32JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } else if (os.getText().equals("windows")) { packr(Platform.windows, winJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } else if (os.getText().equals("macOSX")) { packr(Platform.mac, osxJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } else if (os.getText().equals("all")) { packr(Platform.linux64, linux64JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); packr(Platform.linux32, linux32JRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); packr(Platform.windows, winJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); packr(Platform.mac, osxJRE.getText(), projectName, jarDir + jarName, DESKTOP_LAUNCHER, dir.getText()); } } } else if (arch.getText().equals("android")) { String params = versionParam + "-PversionCode=" + androidVersionCode.getText() + " " + "-Pkeystore=" + androidKeyStore.getText() + " " + "-PstorePassword=" + androidKeyStorePassword.getText() + " " + "-Palias=" + androidKeyAlias.getText() + " " + "-PkeyPassword=" + androidKeyAliasPassword.getText() + " "; // UPDATE 'local.properties' with the android SDK location. if (androidSDK.getText() != null && !androidSDK.getText().trim().isEmpty()) { String sdk = androidSDK.getText(); Properties p = new Properties(); p.setProperty("sdk.dir", sdk); p.store(new FileOutputStream( new File(Ctx.project.getProjectDir().getAbsolutePath(), "local.properties")), null); } if (RunProccess.runGradle(Ctx.project.getProjectDir(), params + "android:assembleRelease")) { String apk = Ctx.project.getProjectDir().getAbsolutePath() + "/android/build/outputs/apk/android-release.apk"; File f = new File(apk); // FileUtils.copyFileToDirectory(f, new File(dir.getText())); FileUtils.copyFile(f, new File(dir.getText(), projectName + "-" + version.getText() + ".apk")); } else { msg = "Error Generating package"; } } else if (arch.getText().equals("ios")) { if (RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:createIPA")) { FileUtils.copyDirectory( new File(Ctx.project.getProjectDir().getAbsolutePath() + "/ios/build/robovm/"), new File(dir.getText())); } else { msg = "Error Generating package"; } } else if (arch.getText().equals("html")) { if (RunProccess.runGradle(Ctx.project.getProjectDir(), "html:dist")) { FileUtils.copyDirectory( new File(Ctx.project.getProjectDir().getAbsolutePath() + "/html/build/dist"), new File(dir.getText())); } else { msg = "Error Generating package"; } } return msg; }