當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。