List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:com.depas.utils.FileUtils.java
public static void writePropertiesToFile(String filePath, Properties properties, String comments) throws IOException { String decodedFilePath = URLDecoder.decode(filePath, "UTF-8"); try (OutputStream out = new FileOutputStream(decodedFilePath)) { properties.store(out, comments); }/* w w w. j a v a 2s . c o m*/ }
From source file:net.rptools.maptool.model.AssetManager.java
/** * Serialize the asset into the persistent cache. * /*from w ww . j a va2 s . c om*/ * @param asset * Asset to serialize */ private static void putInPersistentCache(final Asset asset) { if (!usePersistentCache) { return; } if (!assetIsInPersistentCache(asset)) { final File assetFile = getAssetCacheFile(asset); new Thread() { @Override public void run() { try { assetFile.getParentFile().mkdirs(); // Image OutputStream out = new FileOutputStream(assetFile); out.write(asset.getImage()); out.close(); } catch (IOException ioe) { log.error("Could not persist asset while writing image data", ioe); return; } } }.start(); } if (!assetInfoIsInPersistentCache(asset)) { File infoFile = getAssetInfoFile(asset); try { // Info OutputStream out = new FileOutputStream(infoFile); Properties props = new Properties(); props.put(NAME, asset.getName() != null ? asset.getName() : ""); props.store(out, "Asset Info"); out.close(); } catch (IOException ioe) { log.error("Could not persist asset while writing image properties", ioe); return; } } }
From source file:io.mesosphere.mesos.frameworks.cassandra.executor.ProdObjectFactory.java
private static void modifyCassandraRackdc(@NotNull final Marker taskIdMarker, @NotNull final String version, @NotNull final CassandraServerConfig serverConfig) throws IOException { LOGGER.info(taskIdMarker, "Building cassandra-rackdc.properties"); final Properties props = new Properties(); final RackDc rackDc = serverConfig.getRackDc(); props.put("dc", rackDc.getDc()); props.put("rack", rackDc.getRack()); // Add a suffix to a datacenter name. Used by the Ec2Snitch and Ec2MultiRegionSnitch to append a string to the EC2 region name. //props.put("dc_suffix", ""); // Uncomment the following line to make this snitch prefer the internal ip when possible, as the Ec2MultiRegionSnitch does. //props.put("prefer_local", "true"); final File cassandraRackDc = new File("apache-cassandra-" + version + "/conf/cassandra-rackdc.properties"); try (BufferedWriter bw = new BufferedWriter(new FileWriter(cassandraRackDc))) { props.store(bw, "Created by Apache Mesos Cassandra framework"); }//w w w .j av a 2s . c o m }
From source file:com.android.sdklib.repository.legacy.remote.internal.DownloadCache.java
private static void saveProperties(@NonNull File file, @NonNull Properties props, @NonNull String comments, @NonNull FileOp fop) throws IOException { try (OutputStream fos = fop.newFileOutputStream(file)) { props.store(fos, comments); }//from w w w. j ava 2 s . co m }
From source file:com.t3.model.AssetManager.java
/** * Serialize the asset into the persistent cache. * //from w w w. j ava2s .co m * @param asset * Asset to serialize */ private static void putInPersistentCache(final Asset asset) { if (!usePersistentCache) { return; } if (!assetIsInPersistentCache(asset)) { final File assetFile = getAssetCacheFile(asset); new Thread() { @Override public void run() { assetFile.getParentFile().mkdirs(); try (OutputStream out = new FileOutputStream(assetFile)) { out.write(asset.getImage()); } catch (IOException ioe) { log.error("Could not persist asset while writing image data", ioe); return; } } }.start(); } if (!assetInfoIsInPersistentCache(asset)) { File infoFile = getAssetInfoFile(asset); try { // Info Properties props = new Properties(); props.put(NAME, asset.getName() != null ? asset.getName() : ""); try (OutputStream out = new FileOutputStream(infoFile)) { props.store(out, "Asset Info"); } } catch (IOException ioe) { log.error("Could not persist asset while writing image properties", ioe); return; } } }
From source file:com.meltmedia.cadmium.core.util.WarUtils.java
/** * Adds a properties file to a war.//w ww . j a va2s .c o m * @param outZip The zip output stream to add to. * @param cadmiumPropertiesEntry The entry to add. * @param cadmiumProps The properties to store in the zip file. * @param newWarNames The first element of this list is used in a comment of the properties file. * @throws IOException */ public static void storeProperties(ZipOutputStream outZip, ZipEntry cadmiumPropertiesEntry, Properties cadmiumProps, List<String> newWarNames) throws IOException { ZipEntry newCadmiumEntry = new ZipEntry(cadmiumPropertiesEntry.getName()); outZip.putNextEntry(newCadmiumEntry); cadmiumProps.store(outZip, "Initial git properties for " + newWarNames.get(0)); outZip.closeEntry(); }
From source file:io.fabric8.maven.proxy.impl.MavenProxyServletSupportTest.java
private static void addPom(JarOutputStream jas, String groupId, String artifactId, String version) throws Exception { Properties properties = new Properties(); properties.setProperty("groupId", groupId); properties.setProperty("artifactId", artifactId); properties.setProperty("version", version); ByteArrayOutputStream baos = new ByteArrayOutputStream(); properties.store(baos, null); addEntry(jas, String.format("META-INF/maven/%s/%s/%s/pom.properties", groupId, artifactId, version), baos.toByteArray());//w w w . j a v a 2s . c o m }
From source file:com.vmware.bdd.cli.commands.CommandsUtils.java
public static void writeProperties(Properties properties, String propertiesFilePath) { FileOutputStream fos = null;/*from w w w .jav a2s . co m*/ try { Properties prop = null; File file = new File(propertiesFilePath); if (file.exists()) { prop = new Properties(); prop.load(new FileInputStream(propertiesFilePath)); prop.putAll(properties); } else { prop = properties; } fos = new FileOutputStream(propertiesFilePath); prop.store(fos, ""); } catch (IOException e) { System.out.println(e.getMessage()); } finally { if (fos != null) { try { fos.close(); } catch (IOException e1) { System.out.println(e1.getMessage()); } } } }
From source file:info.magnolia.cms.security.SecurityUtil.java
public static void updateKeys(MgnlKeyPair keys) { // update filestore only when private key is present if (keys.getPrivateKey() != null) { String path = SystemProperty.getProperty(KEY_LOCATION_PROPERTY); try {/*from w ww .ja v a2s . c om*/ Properties defaultProps = new Properties(); defaultProps.put(PRIVATE_KEY, keys.getPrivateKey()); defaultProps.put(PUBLIC_KEY, keys.getPublicKey()); File keystore = new File(path); File parentFile = keystore.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } FileWriter writer = new FileWriter(keystore); String date = new SimpleDateFormat("dd.MMM.yyyy hh:mm").format(new Date()); defaultProps.store(writer, "generated " + date + " by " + MgnlContext.getUser().getName()); writer.close(); } catch (FileNotFoundException e) { throw new SecurityException( "Failed to store private key. Please make sure the key is located in " + path, e); } catch (IOException e) { throw new SecurityException( "Failed to store private key. Please make sure the key is located in " + path, e); } } try { Session session = MgnlContext.getSystemContext().getJCRSession("config"); session.getNode("/server/activation").setProperty("publicKey", keys.getPublicKey()); session.save(); } catch (RepositoryException e) { throw new SecurityException("Failed to store public key.", e); } }
From source file:emperior.Main.java
public static void updateResumeTask(String task) { if (!adminmode) { Properties properties = new Properties(); try {//from www. j a va2 s. co m BufferedInputStream stream = new BufferedInputStream(new FileInputStream("Emperior.properties")); properties.load(stream); properties.setProperty("resumetask", task); BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("Emperior.properties")); properties.store(out, ""); out.close(); stream.close(); } catch (Exception e) { } } }