List of usage examples for java.util Properties Properties
public Properties()
From source file:com.tunyk.jsonbatchtranslate.api.JsonBatchTranslateTest.java
@BeforeClass public static void setUp() throws IOException { Properties properties = new Properties(); URL url = ClassLoader.getSystemResource("config.properties"); properties.load(url.openStream());// w ww. jav a 2 s . c om googleTranslateApiKey = properties.getProperty("google.translate.api.key"); microsoftTranslatorApiKey = properties.getProperty("microsoft.translator.api.key"); yandexApiKey = null; in = FileUtils.readFileToString(new File(ClassLoader.getSystemResource("input.json").getPath())); }
From source file:net.erdfelt.android.sdkfido.Build.java
public static String getVersion() { if (version == null) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); String resource = String.format("META-INF/maven/%s/%s/pom.properties", GROUP_ID, ARTIFACT_ID); URL url = cl.getResource(resource); if (url == null) { version = "[DEV]"; } else {//from w w w .j a v a 2 s . c o m InputStream in = null; try { in = url.openStream(); Properties props = new Properties(); props.load(in); version = props.getProperty("version"); } catch (IOException e) { LOG.log(Level.WARNING, "Unable to read: " + url, e); version = "[UNKNOWN]"; } finally { IOUtils.closeQuietly(in); } } } return version; }
From source file:net.sf.dsig.helpers.UserHomeSettingsParser.java
public static Properties parse() { try {/*from w ww . j a v a2 s . c o m*/ String userHome = System.getProperty("user.home"); File dsigFolder = new File(userHome, ".dsig"); if (!dsigFolder.exists() && !dsigFolder.mkdir()) { throw new IOException("Could not create .dsig folder in user home directory"); } File settingsFile = new File(dsigFolder, "settings.properties"); if (!settingsFile.exists()) { InputStream is = UserHomeSettingsParser.class.getResourceAsStream("/defaultSettings.properties"); if (is != null) { IOUtils.copy(is, new FileOutputStream(settingsFile)); } } if (settingsFile.exists()) { Properties p = new Properties(); FileInputStream fis = new FileInputStream(settingsFile); p.load(fis); IOUtils.closeQuietly(fis); return p; } } catch (IOException e) { logger.warn("Error while initialize settings", e); } return null; }
From source file:com.sarm.Travelogue.process.DestinationProcessorRegressorTest.java
@BeforeClass public static void setUpClass() { logger.info("DestinationProcessorRegressorTest Commencing loading test properties ..."); Properties prop = new Properties(); String propFileName = LonelyConstants.testPropertyFile; try (InputStream input = new FileInputStream(propFileName)) { if (input == null) { logger.debug("input Stream for test.properties file : is Null "); throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); }// w w w. j a v a 2 s . co m logger.debug("Loading properties file " + propFileName); prop.load(input); } catch (FileNotFoundException ex) { logger.debug("FileNotFoundException " + propFileName); ex.printStackTrace(); } catch (IOException ex) { logger.debug("IOException " + propFileName); ex.printStackTrace(); } regressDestinationfile = prop.getProperty(LonelyConstants.regressDestinationfile); try { testMarshall(".//destinations.xml"); } catch (JAXBException | FileNotFoundException | XMLStreamException | UnsupportedEncodingException ex) { ex.printStackTrace(); } }
From source file:com.ebay.jetstream.event.channel.kafka.TestKafkaServer.java
private static Properties createProperties(String logDir, int port, int brokerId, String zkConnect, int numPartitions) { Properties properties = new Properties(); properties.put("port", port + ""); properties.put("broker.id", brokerId + ""); properties.put("num.partitions", numPartitions + ""); properties.put("log.dir", logDir); properties.put("enable.zookeeper", "true"); properties.put("zookeeper.connect", zkConnect); return properties; }
From source file:com.cloudmine.api.BaseDeviceIdentifier.java
/** * Get the unique identifier for this Device and application * @return the unique identifier/*www.j av a 2s .c om*/ * @throws RuntimeException if initialize has not been called */ public String getUniqueId() throws RuntimeException { if (uniqueId == null) { Properties properties = new Properties(); loadPropertiesFile(properties); uniqueId = properties.getProperty(UNIQUE_ID_KEY); if (uniqueId == null) { uniqueId = generateUniqueDeviceIdentifier(); properties.setProperty(UNIQUE_ID_KEY, uniqueId); savePropertiesFile(properties); } } return uniqueId; }
From source file:cu.uci.uengine.utils.FileUtils.java
public static boolean dos2unixFileFixer(String filePath) throws IOException, InterruptedException { // bash es muy sensible a los cambios de linea \r\n de Windows. Para // prevenir que esto cause Runtime Errors, es necesario convertirlos a // un sistema comprensible por ubuntu: \n normal en linux. El comando // dos2unix hace esto. // se lo dejamos a todos los codigos para evitar que algun otro lenguaje // tambien padezca de esto Properties langProps = new Properties(); langProps.load(ClassLoader.getSystemResourceAsStream("uengine.properties")); String dos2unixPath = langProps.getProperty("dos2unix.path"); ProcessBuilder pb = new ProcessBuilder(dos2unixPath, filePath); Process process = pb.start(); process.waitFor();/*from w w w. ja v a2s. c om*/ return process.exitValue() == 0; }
From source file:gov.nih.nci.integration.catissue.CaTissueSpecimenIntegrationTest.java
/** * To initialize the things//w w w. jav a 2 s.c o m * @throws IOException */ @BeforeClass public static void initialize() throws IOException { try { Properties props = new Properties(); props.load(Thread.currentThread().getContextClassLoader() .getResourceAsStream("transcend-ihub-test.properties")); String catissueUserName = props.getProperty("catissue.api.login.username"); String catissuePassword = props.getProperty("catissue.api.login.password"); caTissueParticipantClient = new CaTissueParticipantClient(catissueUserName, catissuePassword); caTissueSpecimenClient = new CaTissueSpecimenClient(catissueUserName, catissuePassword); } catch (BeansException e) { LOG.error("CaTissueConsentIntegrationTest-BeansException inside initialize() ", e); } catch (MalformedURLException e) { LOG.error("CaTissueConsentIntegrationTest-ApplicationException inside initialize() ", e); } }
From source file:sys.core.configuracion.ApplicationHelper.java
public static void cargarLogger() { Logger logger = null;// w w w . ja v a2 s. c o m try { RecursosManager recursosManager = (RecursosManager) WebServletContextListener.getApplicationContext() .getBean("recursosManager"); String rutaLog = ""; { ParametroDto p = recursosManager .obtenerParametroPorID(ConstantesCore.Parametro.PARAMETRO_GENERAL_LOG); if (p.getValorCadena() != null) { rutaLog = p.getValorCadena(); } else { rutaLog = "D:\\log\\FastRemisse"; } } System.out.print("= = = = = = = = = = INICIANDO CONTEXTO FAST REMISSE = = = = = = = = = = "); Properties prop = new Properties(); prop.setProperty("log4j.rootCategory", "INFO, LOGFILE, CONSOLE"); prop.setProperty("log4j.appender.CONSOLE", "org.apache.log4j.ConsoleAppender"); prop.setProperty("log4j.appender.CONSOLE.layout", "org.apache.log4j.PatternLayout"); prop.setProperty("log4j.appender.CONSOLE.layout.ConversionPattern", "[%d{yyyy-MM-dd HH:mm:ss}] - [%5p] (%C{1}.%M:%L) - %m%n"); prop.setProperty("log4j.appender.LOGFILE", "org.apache.log4j.DailyRollingFileAppender"); prop.setProperty("log4j.appender.LOGFILE.file", rutaLog); prop.setProperty("log4j.appender.LOGFILE.DatePattern", "'.'yyyy-MM-dd'.log'"); prop.setProperty("log4j.appender.LOGFILE.MaxFileSize", "2048KB"); prop.setProperty("log4j.appender.archivo.maxFileSize", "20MB"); prop.setProperty("log4j.appender.archivo.maxBackupIndex", "5"); prop.setProperty("log4j.appender.LOGFILE.append", "true"); prop.setProperty("log4j.appender.LOGFILE.layout", "org.apache.log4j.PatternLayout"); prop.setProperty("log4j.appender.LOGFILE.layout.ConversionPattern", "[%d{yyyy-MM-dd HH:mm:ss}] - [%5p] (%C{1}.%M:%L) - %m%n"); //prop.setProperty("log4j.logger.org.springframework", "INFO, LOGFILE, CONSOLE"); //prop.setProperty("log4j.logger.org.hibernate", "INFO, LOGFILE, CONSOLE"); PropertyConfigurator.configure(prop); logger.info( "= = = = = = = = = = CONTEXTO FAST REMISSE CARGADO SATISFACTORIAMENTE = = = = = = = = = = "); System.out.print( "= = = = = = = = = = CONTEXTO FAST REMISSE CARGADO SATISFACTORIAMENTE = = = = = = = = = = "); } catch (Exception e) { BasicConfigurator.configure(); } }
From source file:com.tilab.fiware.metaware.service.TemplateServiceTest.java
@BeforeClass public static void setUpClass() { testProperties = new Properties(); testProperties.setProperty("db.host", "localhost"); testProperties.setProperty("db.port", "27017"); testProperties.setProperty("db.name", "MetadataRepoTest"); // DB test INSTANCE.setManualProperties(testProperties); INSTANCE.createCoreObjects();/*from ww w . jav a2 s. c o m*/ // Objects definition temp1 = new Template("template name test 1", new TemplateDetails()); temp2 = new Template("template name test 2", new TemplateDetails()); }