private static String versionString() { try { Properties prop = new Properties(); InputStream in = Main.class.getResourceAsStream("/okcurl-version.properties"); prop.load(in); in.close(); return prop.getProperty("version"); } catch (IOException e) { throw new AssertionError("Could not load okcurl-version.properties."); } }
public HeidelTimeAnnotator(String name, Properties props) { this(new File(props.getProperty(HEIDELTIME_PATH_PROPERTY, System.getProperty("heideltime", DEFAULT_PATH))), props.getProperty(HEIDELTIME_LANGUAGE_PROPERTY, "english"), Boolean.valueOf(props.getProperty(HEIDELTIME_OUTPUT_RESULTS, "false"))); }
static Map<String, Object> makeLoggingMap(Properties props) { Map<String, Object> loggingMap = new HashMap<>(); loggingMap.put( "loggerClass", props.getProperty("org.apache.druid.java.util.emitter.logging.class", LoggingEmitter.class.getName()) ); loggingMap.put( "logLevel", props.getProperty("org.apache.druid.java.util.emitter.logging.level", "debug") ); return loggingMap; }
@Override public void init(final FilterConfig filterConfig) throws ServletException { Properties props = new Properties(); URL classLoaderURL = Thread.currentThread().getContextClassLoader().getResource(""); if (null != classLoaderURL) { String configFilePath = Joiner.on(FILE_SEPARATOR).join(classLoaderURL.getPath(), "conf", "auth.properties"); try { props.load(new FileInputStream(configFilePath)); } catch (final IOException ex) { log.warn("Cannot found auth config file, use default auth config."); } } rootUsername = props.getProperty("root.username", ROOT_DEFAULT_USERNAME); rootPassword = props.getProperty("root.password", ROOT_DEFAULT_PASSWORD); guestUsername = props.getProperty("guest.username", GUEST_DEFAULT_USERNAME); guestPassword = props.getProperty("guest.password", GUEST_DEFAULT_PASSWORD); }
public static Map<String, String> parseProperties(String content) throws IOException { Map<String, String> map = new HashMap<>(); if (StringUtils.isEmpty(content)) { logger.warn("You specified the config centre, but there's not even one single config item in it."); } else { Properties properties = new Properties(); properties.load(new StringReader(content)); properties.stringPropertyNames().forEach( k -> map.put(k, properties.getProperty(k)) ); } return map; }
private static Properties updatePropertiesWithOptions(Properties props, String[] args) { Properties allProperties = new Properties(); // copy it so props isn't changed but can be overridden by args for (String key : props.stringPropertyNames()) { allProperties.setProperty(key, props.getProperty(key)); } Properties options = StringUtils.argsToProperties(args); for (String key : options.stringPropertyNames()) { allProperties.setProperty(key, options.getProperty(key)); } return allProperties; }
private String loadConfigFor(String namespace) { String filename = String.format("mockdata-%s.properties", namespace); final Properties prop = ResourceUtils.readConfigFile(filename, new Properties()); Map<String, String> configurations = Maps.newHashMap(); for (String propertyName : prop.stringPropertyNames()) { configurations.put(propertyName, prop.getProperty(propertyName)); } ApolloConfig apolloConfig = new ApolloConfig("someAppId", "someCluster", namespace, "someReleaseKey"); Map<String, String> mergedConfigurations = mergeOverriddenProperties(namespace, configurations); apolloConfig.setConfigurations(mergedConfigurations); return gson.toJson(apolloConfig); }
String home = vm.getSystemProperties().getProperty("java.home"); File f = new File(agent); if (!f.exists()) { agent = home + File.separator + "lib" + File.separator + "management-agent.jar"; f = new File(agent); if (!f.exists()) { throw new IOException("Management agent not found");
public static Properties overWriteProperties(Properties bp, Properties ovp) { for (String propertyName : ovp.stringPropertyNames()) { bp.setProperty(propertyName,ovp.getProperty(propertyName)); } return bp; }
private Properties loadProperties(String propString, boolean useReader) throws IOException { DefaultPropertiesPersister persister = new DefaultPropertiesPersister(); Properties props = new Properties(); if (useReader) { persister.load(props, new StringReader(propString)); } else { persister.load(props, new ByteArrayInputStream(propString.getBytes())); } assertEquals("message1", props.getProperty("code1")); assertEquals("message2", props.getProperty("code2")); return props; }
public Credentials() { try { final Properties creds = new Properties(); creds.load(new FileInputStream(System.getProperty("user.home") + System.getProperty("file.separator") + ".javamail")); from = creds.getProperty("from"); password = creds.getProperty("password"); to = creds.getProperty("to"); } catch (IOException ex) { Logger.getLogger(Credentials.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Set the HTTP status code that this exception resolver will apply for a given * resolved error view. Keys are view names; values are status codes. * <p>Note that this error code will only get applied in case of a top-level request. * It will not be set for an include request, since the HTTP status cannot be modified * from within an include. * <p>If not specified, the default status code will be applied. * @see #setDefaultStatusCode(int) */ public void setStatusCodes(Properties statusCodes) { for (Enumeration<?> enumeration = statusCodes.propertyNames(); enumeration.hasMoreElements();) { String viewName = (String) enumeration.nextElement(); Integer statusCode = Integer.valueOf(statusCodes.getProperty(viewName)); this.statusCodes.put(viewName, statusCode); } }
public static Map<String, String> parseProperties(String content) throws IOException { Map<String, String> map = new HashMap<>(); if (StringUtils.isEmpty(content)) { logger.warn("You specified the config centre, but there's not even one single config item in it."); } else { Properties properties = new Properties(); properties.load(new StringReader(content)); properties.stringPropertyNames().forEach( k -> map.put(k, properties.getProperty(k)) ); } return map; }
public HeidelTimeKBPAnnotator(String name, Properties props) { this.heideltimePath = new File(props.getProperty(HEIDELTIME_PATH_PROPERTY, System.getProperty("heideltime", DEFAULT_PATH))); this.outputResults = Boolean.valueOf(props.getProperty(HEIDELTIME_OUTPUT_RESULTS, "false")); this.language = props.getProperty(HEIDELTIME_LANGUAGE_PROPERTY, "english"); // this.tagList = Arrays.asList(props.getProperty("clean.xmltags", "").toLowerCase().split("\\|")) // .stream().filter(x -> x.length() > 0) // .collect(Collectors.toList()); }
@Override public NacosDataSource getObject() throws Exception { if (!StringUtils.isEmpty(System.getProperties() .getProperty(SentinelDataSourceConstants.NACOS_DATASOURCE_ENDPOINT))) { Properties properties = new Properties(); properties.setProperty(PropertyKeyConst.ACCESS_KEY, this.accessKey); properties.setProperty(PropertyKeyConst.SERVER_ADDR, this.secretKey); properties.setProperty(PropertyKeyConst.ENDPOINT, this.endpoint); properties.setProperty(PropertyKeyConst.NAMESPACE, this.namespace); return new NacosDataSource(properties, groupId, dataId, converter); } return new NacosDataSource(serverAddr, groupId, dataId, converter); }
private static String computeVersion() { Properties props = new Properties(); try { InputStream is = CLI.class.getResourceAsStream("/jenkins/cli/jenkins-cli-version.properties"); if(is!=null) { try { props.load(is); } finally { is.close(); } } } catch (IOException e) { e.printStackTrace(); // if the version properties is missing, that's OK. } return props.getProperty("version","?"); }
+ missingProperties); this.workDir = new File(workDir, Long.toString(System.currentTimeMillis())); if (!this.workDir.exists() && !this.workDir.mkdirs()) { throw new RuntimeException("Cannot create directory " + this.workDir); port = Integer.parseInt(conf.getProperty(KDC_PORT)); String orgName= conf.getProperty(ORG_NAME); String orgDomain = conf.getProperty(ORG_DOMAIN); realm = orgName.toUpperCase(Locale.ENGLISH) + "." + orgDomain.toUpperCase(Locale.ENGLISH);
public static Properties noClobberWriteProperties(Properties bp, Properties ovp) { for (String propertyName : ovp.stringPropertyNames()) { if (bp.containsKey(propertyName)) continue; bp.setProperty(propertyName,ovp.getProperty(propertyName)); } return bp; }
@Override public ReactorConfiguration read() { Properties configuration = new Properties(); applyProfile(loadDefaultProfile(), configuration); for (Properties activeProfile : loadActiveProfiles()) { applyProfile(activeProfile, configuration); } applySystemProperties(configuration); String defaultDispatcherName = configuration.getProperty(PROPERTY_NAME_DEFAULT_DISPATCHER, Environment.SHARED); List<DispatcherConfiguration> dispatcherConfiguration = createDispatcherConfiguration(configuration); return new ReactorConfiguration(dispatcherConfiguration, defaultDispatcherName, configuration); }
private static String readFromOsRelease() throws Exception { try (FileReader fileReader = new FileReader(new File("/etc/os-release"))) { Properties properties = new Properties(); properties.load(fileReader); return unQuote(properties.getProperty("PRETTY_NAME")); } }