properties-file

Delete key and value from a property file?

旧时模样 提交于 2019-12-19 12:24:40
问题 I want to delete key and value which is stored in a property file. How can i do that???? 回答1: First load() it using the java.util.Properties API. Properties properties = new Properties(); properties.load(reader); Then you can use the remove() method. properties.remove(key); And finally store() it to the file. properties.store(writer, null); See also: Properties tutorial 回答2: public class SolutionHash { public static void main(String[] args) throws FileNotFoundException,IOException {

How to create a dynamic Interface with properties file at compile time?

蹲街弑〆低调 提交于 2019-12-19 10:21:27
问题 The problem here is that the property file we use has insanely huge name as the key and most of us run into incorrect key naming issues . so it got me thinking if there's a way to generate the following interface based on the property file. Every change we make to the property file will auto-adjust the Properties interface. Or is there other solution? Property File A=Apple B=Bannana C=Cherry Should Generate The following Interface interface Properties{ public static final String A = "A" //

PropertyPlaceholderConfigurer and environment variables in .properties files

半世苍凉 提交于 2019-12-18 11:10:02
问题 I have a Spring application-context.xml with PropertyPlaceholderConfigurer to get properties' values from .properties file. Main and test source folders have separate .properties file. The issue is that I need to use environment variables in .properties file. But when I do it in the following way: property.name=${env.SYSTEM_PROPERTY} I'm getting the following error: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'beanName' defined in class

How to get properties file from /WEB-INF folder in JSF?

时间秒杀一切 提交于 2019-12-18 05:11:24
问题 I have some properties file in /WEB-INF . And I want to load it in a JSF managed bean. Is there any way to do that? 回答1: Use either ExternalContext#getResource() or ExternalContext#getResourceAsStream() wherein you pass the webcontent-relative path. E.g.: ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Properties properties = new Properties(); // ... properties.load(externalContext.getResourceAsStream("/WEB-INF/file.properties")); This delegates under

How to get properties file from /WEB-INF folder in JSF?

自闭症网瘾萝莉.ら 提交于 2019-12-18 05:11:12
问题 I have some properties file in /WEB-INF . And I want to load it in a JSF managed bean. Is there any way to do that? 回答1: Use either ExternalContext#getResource() or ExternalContext#getResourceAsStream() wherein you pass the webcontent-relative path. E.g.: ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Properties properties = new Properties(); // ... properties.load(externalContext.getResourceAsStream("/WEB-INF/file.properties")); This delegates under

Crashlytics not finding API Key in crashlytics.properties at runtime

依然范特西╮ 提交于 2019-12-18 04:01:47
问题 I'm currently implementing the API Key switching script suggested here, except with build types instead of flavors. My build.gradle looks like this: ... buildTypes { debug { ... set("crashlyticsApiKey", "API_KEY_1") set("crashlyticsApiSecret", "API_SECRET_1") } release { ... set("crashlyticsApiKey", "API_KEY_2") set("crashlyticsApiSecret", "API_SECRET_2") } } ... productFlavors{...} ... File crashlyticsProperties = new File("${project.projectDir.absolutePath}/crashlytics.properties")

Crashlytics not finding API Key in crashlytics.properties at runtime

故事扮演 提交于 2019-12-18 04:01:01
问题 I'm currently implementing the API Key switching script suggested here, except with build types instead of flavors. My build.gradle looks like this: ... buildTypes { debug { ... set("crashlyticsApiKey", "API_KEY_1") set("crashlyticsApiSecret", "API_SECRET_1") } release { ... set("crashlyticsApiKey", "API_KEY_2") set("crashlyticsApiSecret", "API_SECRET_2") } } ... productFlavors{...} ... File crashlyticsProperties = new File("${project.projectDir.absolutePath}/crashlytics.properties")

How can I write Java properties in a defined order?

女生的网名这么多〃 提交于 2019-12-17 18:16:34
问题 I'm using java.util.Properties's store(Writer, String) method to store the properties. In the resulting text file, the properties are stored in a haphazard order. This is what I'm doing: Properties properties = createProperties(); properties.store(new FileWriter(file), null); How can I ensure the properties are written out in alphabetical order, or in the order the properties were added? I'm hoping for a solution simpler than "manually create the properties file". 回答1: As per "The New Idiot's

Spring encrypt and decrypt API key in properties file

纵然是瞬间 提交于 2019-12-14 01:06:27
问题 Original Question I have a properties file located in Tomcat and a properties file for testing located in src/test/resources. At the moment I have the following setup. My properties files are loaded in my XML files config.xml <?xml version="1.0" encoding="UTF-8"?> <!-- Repository and Service layers --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:cache="http://www

access Properties file located in app folder in src file in android

人盡茶涼 提交于 2019-12-13 19:42:19
问题 I want to access a property file from a module root, but failed to find any suitable example to access the property file as many only tells how to access from asset in android. My app structure is as follows, ├── app │ ├── key.properties <--It is my property file, which contains app keys,to be used in app │ └── src <-- Here i want to access the key.properties to access some keys ├── build.gradle ├── gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── local.properties 回答1: Mike M is