Reading properties files

Source: Internet
Author: User

For simple email sending encountered in the project, I put some parameter information in the mail. properties file. below is the file content read

Public static map getsystemmailcount (){
Map map = new hashmap ();
Inputstream = NULL;
Inputstream = new mailutil (). getclass (). getclassloader (). getresourceasstream ("mailconfig. properties ");
Properties prop = new properties ();
Try {
Prop. Load (inputstream );
String mailacount = prop. Get ("mailacount"). tostring ();
String mailpwd = prop. Get ("mailpwd"). tostring ();
String mailsmtp = prop. Get ("mailsmtp"). tostring ();
String mailtype = prop. Get ("mailtype"). tostring ();
String httpurl = prop. Get ("httpurl"). tostring ();
Map. Put ("mailacount", mailacount );
Map. Put ("mailpwd", mailpwd );
Map. Put ("mailsmtp", mailsmtp );
Map. Put ("mailtype", mailtype );
Map. Put ("httpurl", httpurl );
} Catch (ioexception e ){
E. printstacktrace ();
System. Out. println ("failed to read the mailbox configuration file! ");
}
Return map;
}

The code is relatively poor, but it is always able to read data, hoping to be useful to everyone. If you have a better way to operate, please contact us.

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.