当前位置:网站首页>Tips for using the built-in variable props of BeanShell
Tips for using the built-in variable props of BeanShell
2022-07-24 05:17:00 【Agricultural garden】
1 Basic introduction
props mapping java.util Of Properties class
And vars The effect is roughly the same , The difference is vars Is to read and write variables , and props It is mainly used to read and write attributes
vars Can only be used within the current thread group ,props Can be used across thread groups , Because attributes can cross thread groups, but variables don't
vars Save only String perhaps Object,props It can be Hashtable perhaps Object
java.util.Properties This class is thread-safe ; Multiple threads can share one Properties object , Without external synchronization
Official documents :https://tool.oschina.net/uploads/apidocs/jdk-zh/java/util/Properties.html
2 Common methods
2.1 getProperty
Method statement
public String getProperty(String key)
public String getProperty(String key, String defaultValue): When key If it doesn't exist, it returns the default value
function : Searches for properties in this property list with the specified key , If the key is not found in this attribute list , Then recursively check the list of default attributes and their default values . If the attribute is not found , This method returns null
// Attributes exist
encoding = props.getProperty("sampleresult.default.encoding");
log.info("encoding is "+ encoding);
// Property does not exist
shanghia = props.getProperty("shanghia");
log.info("shanghia is " + shenzhen);
// Property does not exist
shanghia = props.getProperty("shanghia","default value");
log.info("shanghia is "+ shanghia);
result :
2.2 setProperty
Method statement
public Object setProperty(String key,String value)
function : Setting property values
props.setProperty("shenzhn","shanghia");
shenzhn = props.getProperty("shenzhn");
log.info("shenzhn is "+shenzhn);
result :
2.3 propertyNames
Method statement
public Enumeration<?> propertyNames()
function : Returns an enumeration of all keys in the property list , If the key with the same name is not found in the main property list , Include the different keys in the default attribute list
pnames = props.propertyNames();
pnames.each{
log.info(it)
}

result :
2.4 size
Method statement
public int size()
function : Returns how many properties there are
pnum =props.size();
log.info("pnum is "+pnum);

result :
边栏推荐
- Introduction to MapReduce
- Binary SCA fingerprint extraction black Technology: go language Reverse Technology
- Learning some contents of vector and iterator
- Sword finger offer special assault edition day 7
- Teach you how to weld CAD design board bottom (for beginners) graphic tutorial
- 线程的介绍
- Jetson设备 faild to download repository information使用小技巧记录
- [basic 8] - processes and threads
- Reading excerpts from Liu run's "bottom logic"
- Chapter 9 using image data
猜你喜欢
![Codeforce:d2. remove the substring (hard version) [greedy string + subsequence]](/img/c1/320e0349e2edda0eb420ed018aa831.png)
Codeforce:d2. remove the substring (hard version) [greedy string + subsequence]

Kingbase v8r6 cluster installation and deployment case - script online one click expansion

IDEA:SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

Chapter 9 using image data

How to avoid the most common mistakes when building a knowledge base?

PSO and mfpso
![Knowledge record of College Physics C in advance in summer [update]](/img/c4/76b669c3229a365a5e2567f7fb824e.png)
Knowledge record of College Physics C in advance in summer [update]

Kingbase V8R6集群安装部署案例---脚本在线一键缩容

Heavy! The 2022 China open source development blue book was officially released

I'm interested in reading efficient reading - the most cost-effective self investment
随机推荐
NFS shared services
C primer plus learning notes - 6. Arrays and pointers
The difference between compiled language and interpreted language
HCIA NAT experiment
Teach you how to weld CAD design board bottom (for beginners) graphic tutorial
Markov random field: definition, properties, maximum a posteriori probability problem, energy minimization problem
Un7.23: how to install MySQL on linix?
The difference between statement and Preparedstatement and how to use placeholders
Basic knowledge of MySQL database
[Basic 6] - encapsulation and inheritance of classes, objects and classes
[basic 8] - processes and threads
PostgreSQL: run PostgreSQL + pgadmin 4 in docker
Beginners' preparation for the Blue Bridge Cup (University Programming learning history records, topic ideas for students who need to prepare for the Blue Bridge Cup)
High performance architecture design of wechat circle of friends
The difference between run and start in thread class
Ben, reducing online importance is the same. Abnormal instance CP operation found
Use of fiddler packet capturing tool
MapReduce介绍
generator生成器,只生成两个方法
Chapter5 foundation of deep learning