List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:PropertiesUtil.java
public static void store(Properties properties, OutputStream outputStream) throws IOException { try {/* w ww. j a v a 2 s . c o m*/ if (properties == null) { throw new IllegalArgumentException("Properties is not set."); } if (outputStream == null) { throw new IllegalArgumentException("OutputStream is not set."); } properties.store(new BufferedOutputStream(outputStream), null); } finally { if (outputStream != null) { outputStream.close(); } } }
From source file:io.hawkcd.agent.AgentConfiguration.java
private static String generateAgentId(Properties properties) { UUID agentId = UUID.randomUUID(); try {/*from w w w . ja va 2 s .co m*/ File configFile = new File(ConfigConstants.AGENT_CONFIG_FILE_LOCATION); OutputStream output = new FileOutputStream(configFile); properties.setProperty("agentId", agentId.toString()); properties.store(output, null); output.close(); } catch (IOException io) { io.printStackTrace(); } return agentId.toString(); }
From source file:com.cssweb.android.common.CssIniFile.java
public static boolean saveIniWithAPPEND(Context context, int parmInt, String key, String value) { FileOutputStream fileOut = null; Properties properties = new Properties(); properties.put(key, value);//w w w .ja v a 2s . co m try { fileOut = context.openFileOutput(GetFileName(parmInt), Context.MODE_APPEND);// properties.store(fileOut, ""); fileOut.close(); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } return true; }
From source file:com.cprassoc.solr.auth.SolrAuthActionController.java
public static String doSavePropertiesAction(Properties props) { String result = "SUCCESS"; try {//from w ww .j ava 2 s .com File f = new File(SolrAuthManager.SOLR_AUTH_PROPERTIES); OutputStream out = new FileOutputStream(f); props.store(out, "SolrAuthManager Properties"); } catch (Exception e) { result = "FAILURE: " + e.toString(); e.printStackTrace(); } return (result); }
From source file:com.cssweb.android.common.CssIniFile.java
public static void saveIni(Context context, int parmInt, String key, String value) { FileOutputStream fileOut = null; Properties properties = new Properties(); properties.put(key, value);/*w w w .j a v a 2 s . c o m*/ try { fileOut = context.openFileOutput(GetFileName(parmInt), Context.MODE_PRIVATE);// properties.store(fileOut, ""); } catch (FileNotFoundException e) { } catch (IOException e) { } finally { try { fileOut.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:dpfmanager.shell.core.DPFManagerProperties.java
public static void setPropertiesConfig(Properties properties) { try {/* w ww .j ava 2 s . co m*/ File configFile = new File(getDataDir() + "/dpfmanager.properties"); if (configFile.exists()) { OutputStream os = new FileOutputStream(configFile); properties.store(os, null); os.close(); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:eu.openanalytics.rsb.component.JobProcessor.java
private static void uploadPropertiesToR(final RServi rServi, final Map<String, Serializable> metas, final Set<String> filesUploadedToR) throws CoreException, IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final Properties properties = new Properties(); for (final Entry<String, Serializable> meta : metas.entrySet()) { properties.setProperty(meta.getKey(), meta.getValue().toString()); }//from ww w .j a va2 s .c o m properties.store(baos, null); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); rServi.uploadFile(bais, bais.available(), Constants.MULTIPLE_FILES_JOB_CONFIGURATION, 0, null); filesUploadedToR.add(Constants.MULTIPLE_FILES_JOB_CONFIGURATION); }
From source file:com.singular.utils.FileUtils.java
public static Path persistConfigurationInHDFS(Configuration configuration, Properties conf, Path remoteBasePath, String fileName) {//from w w w .j a v a2 s .c om OutputStream out = null; Path remotePath = null; try { remotePath = new Path(remoteBasePath, fileName); FileSystem remoteFs = FileSystem.get(configuration); out = remoteFs.create(remotePath); conf.store(out, null); } catch (Exception e) { e.printStackTrace(); throw new SingularException("Exception while persisting configuration.", e); } finally { try { if (out != null) { out.close(); } } catch (IOException e) { e.printStackTrace(); } } return remotePath; }
From source file:ac.simons.tweetarchive.Application.java
static void createTwitterOauthTokens(final String consumerKey, final String consumerSecret) throws Exception { final Twitter twitter = TwitterFactory.getSingleton(); twitter.setOAuthConsumer(consumerKey, consumerSecret); final RequestToken requestToken = twitter.getOAuthRequestToken(); AccessToken accessToken = null;/*w w w .ja v a2 s . c om*/ final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (null == accessToken) { System.out.println("Open the following URL and grant access to your account:"); System.out.println(requestToken.getAuthorizationURL()); System.out.print("Enter the PIN(if aviailable) or just hit enter.[PIN]:"); String pin = br.readLine(); try { if (pin.length() > 0) { accessToken = twitter.getOAuthAccessToken(requestToken, pin); } else { accessToken = twitter.getOAuthAccessToken(); } } catch (TwitterException te) { if (401 == te.getStatusCode()) { System.out.println("Unable to get the access token."); } else { throw te; } } } final Properties properties = new Properties(); properties.put("twitter4j.oauth.consumerKey", consumerKey); properties.put("twitter4j.oauth.consumerSecret", consumerSecret); properties.put("twitter4j.oauth.accessToken", accessToken.getToken()); properties.put("twitter4j.oauth.accessTokenSecret", accessToken.getTokenSecret()); try (final FileOutputStream out = new FileOutputStream("application.properties", true)) { properties.store(out, null); } }
From source file:org.aliuge.crawler.fetcher.Fetcher.java
private static void storeProxyIp() { // ? ???ip//from w ww .j a v a 2 s . co m Properties pro = new Properties(); for (int i = 0; i < proxyIps.size(); i++) { pro.setProperty("proxy" + i, proxyIps.get(i)); } OutputStream out = null; try { out = new FileOutputStream(new File(config.getProxyPath())); pro.store(out, "?Ip,[" + DateTimeUtil.getDateTime() + "]"); } catch (FileNotFoundException e) { slog.error("?IP????:" + new File(config.getProxyPath()).toString(), e); e.printStackTrace(); } catch (IOException e) { slog.error("?Ip:", e); e.printStackTrace(); } finally { try { out.close(); } catch (IOException e) { } } }