当前位置: 首页>>代码示例>>Java>>正文


Java Properties类代码示例

本文整理汇总了Java中java.util.Properties的典型用法代码示例。如果您正苦于以下问题:Java Properties类的具体用法?Java Properties怎么用?Java Properties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Properties类属于java.util包,在下文中一共展示了Properties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeURLParameters

import java.util.Properties; //导入依赖的package包/类
public static String makeURLParameters(final Properties params) {
  final StringBuffer result = new StringBuffer(100);
  if (!params.isEmpty()) {
    boolean first = true;
    final Set set = params.entrySet();
    for (final Iterator i = set.iterator(); i.hasNext(); ) {
      final Map.Entry entry = (Map.Entry) i.next();
      if (first) {
        result.append('?');
        first = false;
      } else {
        result.append('&');
      }
      result.append((String) entry.getKey());
      result.append('=');
      result.append((String) entry.getValue());
    }
  }
  return result.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:WebuiUtils.java

示例2: Database

import java.util.Properties; //导入依赖的package包/类
public Database() throws FileNotFoundException, IOException {
	Properties properties = new Properties();
	properties.load(new FileInputStream("src/main/resources/database.properties"));
	username = properties.getProperty("username");
	password = properties.getProperty("password");
	hostname = properties.getProperty("url");
	database = properties.getProperty("name");
	port = properties.getProperty("port");
}
 
开发者ID:PawelBogdan,项目名称:BecomeJavaHero,代码行数:10,代码来源:Database.java

示例3: goal

import java.util.Properties; //导入依赖的package包/类
private static Goal goal(Class<? extends Goal> goalClass) throws Exception {
  Properties props = CruiseControlUnitTestUtils.getCruiseControlProperties();
  props.setProperty(KafkaCruiseControlConfig.MAX_REPLICAS_PER_BROKER_CONFIG, Long.toString(1L));
  BalancingConstraint balancingConstraint = new BalancingConstraint(new KafkaCruiseControlConfig(props));
  balancingConstraint.setBalancePercentage(TestConstants.LOW_BALANCE_PERCENTAGE);
  balancingConstraint.setCapacityThreshold(TestConstants.MEDIUM_CAPACITY_THRESHOLD);
  
  try {
    Constructor<? extends Goal> constructor = goalClass.getDeclaredConstructor(BalancingConstraint.class);
    constructor.setAccessible(true);
    return constructor.newInstance(balancingConstraint);
  } catch (NoSuchMethodException badConstructor) {
    //Try default constructor
    return goalClass.newInstance();
  }
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:17,代码来源:ExcludedTopicsTest.java

示例4: testBug10630

import java.util.Properties; //导入依赖的package包/类
/**
 * Tests fix for BUG#10630, Statement.getWarnings() fails with NPE if
 * statement has been closed.
 */
public void testBug10630() throws Exception {
    Connection conn2 = null;
    Statement stmt2 = null;

    try {
        conn2 = getConnectionWithProps((Properties) null);
        stmt2 = conn2.createStatement();

        conn2.close();
        stmt2.getWarnings();
        fail("Should've caught an exception here");
    } catch (SQLException sqlEx) {
        assertEquals(SQLError.SQL_STATE_ILLEGAL_ARGUMENT, sqlEx.getSQLState());
    } finally {
        if (stmt2 != null) {
            stmt2.close();
        }

        if (conn2 != null) {
            conn2.close();
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:28,代码来源:StatementRegressionTest.java

示例5: getLoaderData

import java.util.Properties; //导入依赖的package包/类
private LoaderData getLoaderData(Path rootPath) {
    String os = getOS();

    try {
        Path inputPath = rootPath.resolve("manifest.properties");
        Properties prop = new Properties();
        prop.load(Files.newInputStream(inputPath));

        String mainClass = prop.getProperty("main");
        String classPath = prop.getProperty(os);

        if(classPath == null)
            throw error("Your system configuration ("+os+") is not supported in this build.", null);

        return new LoaderData(mainClass, classPath.split(":"));
    } catch (Exception e) {
        throw error("Could not load library manifest.", e);
    }
}
 
开发者ID:Lymia,项目名称:PrincessEdit,代码行数:20,代码来源:Loader.java

示例6: createPool

import java.util.Properties; //导入依赖的package包/类
public static void createPool(PoolAttributes poolAttr) throws Exception {
  Properties props = new Properties();
  props.setProperty(MCAST_PORT, "0");
  props.setProperty(LOCATORS, "");

  DistributedSystem ds = new CacheServerTestUtil().getSystem(props);;

  PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
  pf.init(poolAttr);
  PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.LOCAL);
  factory.setPoolName(p.getName());

  RegionAttributes attrs = factory.create();
  pool = p;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:CacheServerTestUtil.java

示例7: testSendMail_invServer

import java.util.Properties; //导入依赖的package包/类
/**
 * Execute send mail without a valid server.
 */
@Test(expected = MailOperationException.class)
public void testSendMail_invServer() throws Exception {
    List<UserData> userData = new ArrayList<UserData>();
    UserData ud = new UserData();
    ud.email = testMailAddress;
    ud.userid = "newid";
    ud.olduserid = "oldid";
    userData.add(ud);

    Properties unProperties = getProperties(
            getProperiesForComputerName(unPropertiesFilePath));

    unProperties.setProperty(HandlerUtils.MAIL_SERVER, "invalidServer");
    userNotification.sendMail(userData, unProperties);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:UserNotificationIT.java

示例8: loadServerParameters

import java.util.Properties; //导入依赖的package包/类
private ServerParameters loadServerParameters(Properties serverProperties) {
    ServerParameters parameters = new ServerParameters();
    parameters.setServerUrl(serverProperties.getProperty(SERVER_URL_PROPERTY));
    parameters.setAuthPayload(serverProperties.getProperty(AUTHENTICATION_PROPERTY));
    parameters.setAuthenticationUrl(serverProperties.getProperty(AUTHENTICATION_URL_PROPERTY));
    parameters.setSearchUrl(serverProperties.getProperty(SEARCH_URL_PROPERTY));
    parameters.setRegistrationUrl(serverProperties.getProperty(REGISTRATION_URL_PROPERTY));
    parameters.setProjectLoadUrl(serverProperties.getProperty(PROJECT_URL_PROPERTY));
    parameters.setProjectLoadByIdUrl(serverProperties.getProperty(PROJECT_URL_BY_ID_PROPERTY));
    parameters.setFileFindUrl(serverProperties.getProperty(FIND_FILE_URL_PROPERTY));
    parameters.setVersionUrl(serverProperties.getProperty(VERSION_URL_PROPERTY));
    parameters.setMinSupportedServerVersion(
            Integer.parseInt(serverProperties.getProperty(SERVER_VERSION_PROPERTY)));
    parameters.setProjectTreeUrl(serverProperties.getProperty(PROJECT_TREE_URL_PROPERTY));
    return parameters;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:17,代码来源:CommandManager.java

示例9: test

import java.util.Properties; //导入依赖的package包/类
@Test
public void test()
{
    ConfigFactory.Instance().LoadProperties("/home/hank/Desktop/rainbow/rainbow-evaluate/rainbow.properties");
    Properties params = new Properties();
    params.setProperty("method", "PRESTO");
    params.setProperty("format", "ORC");
    params.setProperty("table.dir", "/rainbow2/orc");
    params.setProperty("table.name", "orc");
    params.setProperty("workload.file", "/home/hank/Desktop/rainbow/rainbow-evaluate/workload.txt");
    params.setProperty("log.dir", "/home/hank/Desktop/rainbow/rainbow-evaluate/workload_eva/");
    params.setProperty("drop.cache", "false");

    Invoker invoker = new InvokerWorkloadEvaluation();
    try
    {
        invoker.executeCommands(params);
    } catch (InvokerException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:23,代码来源:TestWorkloadEvaluation.java

示例10: configureAttachSettings

import java.util.Properties; //导入依赖的package包/类
private boolean configureAttachSettings(boolean partially) {
    AttachSettings settings = AttachWizard.getDefault().configure(attachSettings, partially);
    if (settings == null) return false; // cancelled by the user
    
    attachSettings = settings;
    final AttachSettings as = new AttachSettings();
    attachSettings.copyInto(as);
    final Lookup.Provider lp = session.getProject();
    RequestProcessor.getDefault().post(new Runnable() {
        public void run() {
            Properties p = new Properties();
            as.store(p);
            try {
                ProfilerStorage.saveProjectProperties(p, lp, "attach"); // NOI18N
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
        
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ProfilerWindow.java

示例11: setupConnection

import java.util.Properties; //导入依赖的package包/类
public Connection setupConnection(Connection connection, Properties properties) throws Exception {

        InputStream is = SqlCommon.class.getClassLoader().getResourceAsStream("application.properties");
        properties.load(is);
        String user     = String.valueOf(properties.get("sql-connector.user"));
        String password = String.valueOf(properties.get("sql-connector.password"));
        String url      = String.valueOf(properties.get("sql-connector.url"));

        System.out.println("Connecting to the database for unit tests");
        try {
            connection = DriverManager.getConnection(url,user,password);
        } catch (Exception ex) {
            fail("Exception during database startup.");
        }
        return connection;
    }
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:SqlCommon.java

示例12: configureLegacyPropertyComponents

import java.util.Properties; //导入依赖的package包/类
private void configureLegacyPropertyComponents() {
	final Properties legacyProperties = LegacySettingsController.getLegacyProperties().orElse(new Properties());
	initLegacySettings(legacyProperties);

	fpsLimitSpinner.valueProperty().addListener(__ -> changeLegacyIntegerSetting(LegacySettingsController.FPS_LIMIT, fpsLimitSpinner.getValue()));
	pageSizeSpinner.valueProperty().addListener(__ -> changeLegacyIntegerSetting(LegacySettingsController.PAGE_SIZE, pageSizeSpinner.getValue()));

	multicoreCheckbox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.MULTICORE, multicoreCheckbox.isSelected()));
	audioMsgCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.AUDIO_MESSAGE_OFF, !audioMsgCheckBox.isSelected()));
	audioproxyCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.AUDIO_PROXY_OFF, !audioproxyCheckBox.isSelected()));
	timestampsCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.TIMESTAMP, timestampsCheckBox.isSelected()));
	headMoveCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.HEAD_MOVE, !headMoveCheckBox.isSelected()));
	imeCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.IME, imeCheckBox.isSelected()));
	directModeCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.DIRECT_MODE, directModeCheckBox.isSelected()));
	nameTagStatusCheckBox.setOnAction(__ -> changeLegacyBooleanSetting(LegacySettingsController.NO_NAME_TAG_STATUS, !nameTagStatusCheckBox.isSelected()));
}
 
开发者ID:Bios-Marcel,项目名称:ServerBrowser,代码行数:17,代码来源:SettingsController.java

示例13: testSaveWithWriter

import java.util.Properties; //导入依赖的package包/类
public void testSaveWithWriter() throws IOException, ParserConfigurationException {
    propertySet.setBoolean("testBoolean", true);
    propertySet.setData("testData", "value1".getBytes());
    propertySet.setDate("testDate", new Date());
    propertySet.setDouble("testDouble", 10.245D);
    propertySet.setInt("testInt", 7);
    propertySet.setLong("testLong", 100000);
    propertySet.setObject("testObject", new TestObject(1));

    Properties props = new Properties();
    props.setProperty("prop1", "value1");
    propertySet.setProperties("testProperties", props);
    propertySet.setString("testString", "value1");
    propertySet.setText("testText", TEXT_VALUE);

    StringWriter writer = new StringWriter();
    ((XMLPropertySet) propertySet).save(writer);
    assertNotNull(writer.toString());
}
 
开发者ID:will-gilbert,项目名称:OSWf-OSWorkflow-fork,代码行数:20,代码来源:XMLTest.java

示例14: start

import java.util.Properties; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws IOException {

	/* 앱 버전 */
	Properties prop = new Properties();
	FileInputStream fis = new FileInputStream(Constants.SystemMessage.PROPERTY_PATH);
	prop.load(new java.io.BufferedInputStream(fis));
	String current = prop.getProperty(Constants.SystemMessage.PROPERTY_APP_KEY);

	/* 업데이트 앱 버전 체크 */
	ApplicationAPI api = new ApplicationAPI();
	Map<String, String> result = api.appCheck();
	String now = result.get("new_version");

	if (current != null && now != null) {
		if (!current.equals(now)) {
			AlertSupport alert = new AlertSupport(Constants.AlertInfoMessage.VERSION_UPDATE_MESSAGE);
			int c = alert.alertConfirm();
			if (c == 1) {
				Runtime runTime = Runtime.getRuntime();
				try {
					primaryStage.close();
					runTime.exec(Constants.SystemMessage.UPDATE_APP_PATH);
				} catch (IOException e) {
					e.printStackTrace();
				}
			} else {
				// 업데이트를 하지 않을 때
				run(primaryStage, current);
			}
		} else {
			// 최신버전일때
			run(primaryStage, current);
		}
	}
}
 
开发者ID:kimyearho,项目名称:WebtoonDownloadManager,代码行数:37,代码来源:Main.java

示例15: bindProperties

import java.util.Properties; //导入依赖的package包/类
public static void bindProperties(Object object, Properties properties,
        String prefix) {
    if (properties == null) {
        throw new IllegalArgumentException(
                "there is no properties setting.");
    }

    logger.debug("prefix : {}", prefix);

    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();

        if (!key.startsWith(prefix)) {
            continue;
        }

        String propertyName = key.substring(prefix.length());

        tryToSetProperty(object, propertyName, value);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:PropertiesUtils.java


注:本文中的java.util.Properties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。