Obtain the parameters set in the. properties configuration file in the java class.

Source: Internet
Author: User

How to get the parameters in the. properties configuration file, I did not understand it on the internet for a long time. Later I found the parameters in previous projects and wrote them down to avoid forgetting.

1. configuration file: message_product.properties

01
Total_product = 2
02
Service1 = 1. New Stock Issuance SMS Reminder Service, details of issuance
03
Service2 = 2, allotment text message Reminder Service & additional text message Reminder Service, additional details
04
 
05
Validatecode_temp = verification code: $ {vilidateCode }.
06
 
07
# Message continuous sending time, in the unit of "hour"
08
Message_constant_time = 24
09
 
10
# Message encoding format 15 GBK encoding 30 MMS 31 wappush 32 long SMS 33 personalized MMS'
11
Message_formart = 15
12
 
13
# 'Message priority: 0 lowest --- 3 highest ';
14
Message_priority = 3
15
 
16
# 'Type of message delivery: 0 free delivery 1 one by line 2 Subscription 3 subscription request 4 cancellation request 5 subscription fee deduction ';
17
Message_type = 0
18
 
19
# Product ID numproductid
20
Message _ product_id = 724
21
# Numchannelid
22
Message_channelid = 0
2. java class
01
Package com. margin. utils;
02
 
03
Import java. io. UnsupportedEncodingException;
04
Import java. util. ResourceBundle;
05
 
06
Import com. margin. po. MessageProduct;
07
 
08
Public class MessageProperties {
09
Private static ResourceBundle rb;
10
 
11
Static {
12
Rb = ResourceBundle. getBundle ("message_product ");
13
}
14

15
/**
16
* Get the total number of SMS services.
17
* <A href = "http://my.oschina.net/u/556800" target = "_ blank" rel = "nofollow"> @ return </a>
18
*/
19
Public static int getTotalProduct (){
20
Return Integer. parseInt (rb. getString ("total_product "));
21
}
View sourceprint?
01
/**
02
* Message continuous sending time
03
* <A href = "http://my.oschina.net/u/556800" target = "_ blank" rel = "nofollow"> @ return </a>
04
*/
05
Public static int getMessageConstantTime ()
06
{
07
Return Integer. parseInt (rb. getString ("message_constant_time"). trim ());
08
}
09
 
10
/**
11
* Message format
12
* <A href = "http://my.oschina.net/u/556800" target = "_ blank" rel = "nofollow"> @ return </a>
13
*/
14
Public static int getMessageFormat ()
15
{
16
Return Integer. parseInt (rb. getString ("message_formart"). trim ());
17
}
18
 
19
/**
20
* Message sending priority
21
* <A href = "http://my.oschina.net/u/556800" target = "_ blank" rel = "nofollow"> @ return </a>
22
*/
23
Public static int getMessagePriority ()
24
{
25
Return Integer. parseInt (rb. getString ("message_priority"). trim ());
26
}
Author: Ye Zhiqiu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.