List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:it.scoppelletti.security.keygen.KeyGeneratorBean.java
/** * Esegue l’operazione./* w w w . j ava 2 s . co m*/ */ public void run() { Properties props; OutputStream out = null; Key key; KeyGenerator keyGen; if (myConfigFile == null) { throw new PropertyNotSetException(toString(), "configFile"); } try { props = loadConfig(); out = openOutput(); if (out == null) { return; } keyGen = CryptoUtils.getKeyGenerator(props, myPrefix); key = keyGen.generateKey(); props = CryptoUtils.toProperties(key, myEncoded); props.store(out, null); } catch (IOException ex) { throw new IOOperationException(ex); } finally { if (out != null && myOutputFile != null) { IOUtils.close(out); out = null; } } }
From source file:org.netxilia.api.impl.storage.DataSourceConfigurationServiceImpl.java
private void saveWorkbookToDataSourceFile(Properties props) throws StorageException { FileWriter writer = null;// w w w . j av a2s .c o m try { File propFile = new File(getPath(), workbooksFile); writer = new FileWriter(propFile); props.store(writer, "Saved by Netxilia"); } catch (IOException e) { throw new StorageException(e); } finally { if (writer != null) { try { writer.flush(); } catch (Exception e2) { throw new StorageException(e2); } IOUtils.closeQuietly(writer); } } }
From source file:com.tcloud.bee.key.server.service.impl.KeyManageServiceImpl.java
@Override public QueryResult updateKeyUsers(Param param, String userName) throws FileNotFoundException, IOException { logger.info("User is trying to update key users. userName:" + userName + ", keyName:" + param.getKeyName()); File keyfile = new File(env.getProperty("keyfile.path") + param.getKeyName()); if (!keyfile.exists()) { return new QueryResult(BeeConstants.ResponseStatus.FAIL, BeeConstants.ErrorMap.get(BeeConstants.ResponseCode.ERROR_KM_KEYNAME_NOT_FOUND), null); }//from w w w. j av a 2s . c o m Properties prop = new Properties(); prop.load(new FileInputStream(keyfile)); String owner = prop.getProperty("owner"); if (!owner.equals(userName)) { logger.info("You(" + userName + ") are not the owner of key(" + param.getKeyName() + ")."); return new QueryResult(BeeConstants.ResponseStatus.FAIL, BeeConstants.ErrorMap.get(BeeConstants.ResponseCode.ERROR_KM_NOT_OWNER), null); } prop.setProperty("users", param.getUsers()); prop.store(new FileOutputStream(env.getProperty("keyfile.path") + param.getKeyName()), null); logger.info("update keyfile \"{}\" of keyfile folder: {}", param.getKeyName(), env.getProperty("keyfile.path")); return new QueryResult(BeeConstants.ResponseStatus.SUCCESS, "User of Key(" + param.getKeyName() + ") updated", null); }
From source file:controllers.ConfigurationController.java
@RequestMapping(value = "/saveconfig", produces = "application/json; charset=utf-8") public @ResponseBody String save(DBConfig config, HttpServletRequest request) { try {/*from w ww. jav a 2 s. co m*/ String path = Utility.getPath("dbconfig", request); path += "config.properties"; Properties p = new Properties(); FileInputStream file = new FileInputStream(path); p.load(file); file.close(); FileOutputStream fOut = new FileOutputStream(path); p.setProperty("prop.db", config.getDb_type().toString()); p.setProperty("prop.server", config.getHost()); p.setProperty("prop.port", config.getPort() + ""); p.setProperty("prop.database", config.getDatabase()); p.setProperty("prop.user", config.getUser()); p.setProperty("prop.passwd", config.getPassword()); p.store(fOut, ""); fOut.close(); return new OperationResult(StatusRetorno.OPERACAO_OK, "", "").toJson(); } catch (Exception ex) { ex.printStackTrace(); } return "0"; }
From source file:com.omertron.pushoverapi.PushoverApi.java
public boolean propertiesSave(String filename) { Properties props = new Properties(); props.setProperty("apptoken", appToken); props.setProperty("usertoken", userToken); if (StringUtils.isNotBlank(device)) { props.setProperty("device", device); }/*from w w w . ja v a2s .c o m*/ FileOutputStream fos = null; try { fos = new FileOutputStream(filename); props.store(fos, "Pushover API Properties"); } catch (IOException ex) { LOG.warn("Unable to save properties file '{}', error: {}", filename, ex.getMessage()); return Boolean.FALSE; } finally { try { fos.close(); } catch (IOException ex) { LOG.debug("Failed to close properties file '{}' properly. Error: {}", filename, ex.getMessage()); } } return Boolean.TRUE; }
From source file:com.github.jengelman.gradle.plugins.integration.TestFile.java
public void writeProperties(Map<?, ?> properties) { Properties props = new Properties(); props.putAll(properties);//from w ww .jav a2s . c o m try { FileOutputStream stream = new FileOutputStream(this); try { props.store(stream, "comment"); } finally { stream.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.piusvelte.hydra.ConnectionManager.java
private void initProps() { Properties properties = new Properties(); properties.put(sPassphrase, "changeit"); properties.put(sDatabases, ""); PrintWriter pw;/*from w w w . j a v a2 s . com*/ try { pw = new PrintWriter(new FileOutputStream(sHydraDir + HYDRA_PROPERTIES)); properties.store(pw, "The passphrase is used to authorize tokens\n Databases should be a comment delimited string of database aliases, followed by their connection properties\n" + " database types:\n unidata\n mysql\n mssql\n oracle\n postgresql\n\nexample:" + "databases=mydb\n" + "mydb.type=unidata\n" + "mydb.database=C:\\U2\\ud73\\demo\n" + "mydb.host=localhost\n" + "mydb.port=31438\n" + "mydb.username=myuser\n" + "mydb.password=mypss\n" + "mydb.connections=1\n" + "mydb.DASU=mydasu\n" + "mydb.DASP=mydasp\n" + "mddb.SQLENVINIT=\n"); pw.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } }
From source file:org.sventon.appl.Application.java
/** * Store the repository configurations on file at path * {@code configurationRootDirectory / [repository name] / configurationFilename}. * <p/>//from w w w. j av a 2 s. c o m * Note: Already stored configurations will be untouched. * * @throws IOException if IO error occur during file operations. */ public void persistRepositoryConfigurations() throws IOException { for (final RepositoryConfiguration repositoryConfig : repositoryConfigurations.getAllConfigurations()) { if (!repositoryConfig.isPersisted()) { final File configDir = getConfigurationDirectoryForRepository(repositoryConfig.getName()); if (!configDir.exists() && !configDir.mkdirs()) { throw new IOException("Unable to create directory: " + configDir.getAbsolutePath()); } final File configFile = new File(configDir, getConfigurationFileName()); logger.info("Storing configuration: " + configFile.getAbsolutePath()); FileOutputStream fileOutputStream = null; try { fileOutputStream = new FileOutputStream(configFile); final Properties configProperties = repositoryConfig.getAsProperties(); logger.debug("Storing properties: " + configProperties); configProperties.store(fileOutputStream, ""); fileOutputStream.flush(); repositoryConfig.setPersisted(); } finally { IOUtils.closeQuietly(fileOutputStream); } } } }
From source file:de.fhg.iais.asc.commons.AscConfiguration.java
public void writeOutPropertiesToFile(String filePath) { Properties property = new Properties(); for (String key : this.propertiesMap.keySet()) { property.put(key, this.propertiesMap.get(key).toString()); }/* ww w. j a v a 2 s . c o m*/ File propertiesFile = new File(filePath); FileOutputStream fos = null; try { fos = new FileOutputStream(propertiesFile); property.store(fos, "ASC properties including provider specific properties"); } catch (Exception e) { throw new DbcException(e); } finally { if (fos != null) { try { fos.close(); } catch (Exception e) { throw new DbcException(e); } } } }
From source file:com.github.drbookings.model.settings.SettingsManager.java
protected void saveAllToFile() { final Properties prop = readProperties(); OutputStream output = null;//from ww w . ja v a 2s .c o m try { output = new FileOutputStream( System.getProperty("user.home") + File.separator + DrBookingsApplication.CONFIG_FILE_PATH); prop.setProperty(DrBookingsApplication.SHOW_NET_EARNINGS_KEY, Boolean.toString(isShowNetEarnings())); prop.store(output, "Dr.Bookings Preferences"); if (logger.isInfoEnabled()) { logger.info("Properties file updated"); } } catch (final IOException io) { if (logger.isErrorEnabled()) { logger.error("Failed to write properties file " + io.toString()); } } finally { IOUtils.closeQuietly(output); } }