Thursday, December 27, 2012

Simple way to read properties file in Java

Copy pasted from Link: http://www.mkyong.com/java/java-properties-file-examples/

package com.mkyong.common;
 
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
 
public class App 
{
    public static void main( String[] args )
    {
     Properties prop = new Properties();
 
     try {
      //set the properties value
      prop.setProperty("database", "localhost");
      prop.setProperty("dbuser", "mkyong");
      prop.setProperty("dbpassword", "password");
 
      //save properties to project root folder
      prop.store(new FileOutputStream("config.properties"), null);
 
     } catch (IOException ex) {
      ex.printStackTrace();
        }
    }
}
 
package com.mkyong.common;
 
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
 
public class App 
{
    public static void main( String[] args )
    {
     Properties prop = new Properties();
 
     try {
               //load a properties file
      prop.load(new FileInputStream("config.properties"));
 
               //get the property value and print it out
                System.out.println(prop.getProperty("database"));
      System.out.println(prop.getProperty("dbuser"));
      System.out.println(prop.getProperty("dbpassword"));
 
     } catch (IOException ex) {
      ex.printStackTrace();
        }
 
    }
}
 
package com.mkyong.common;
 
import java.io.FileInputStream;
import java.io.IOException;
import java.utilutil.Properties;
 
public class App 
{
    public static void main( String[] args )
    {
     Properties prop = new Properties();
 
     try {
               //load a properties file from class path, inside static method
      prop.load(App.class.getClassLoader().getResourceAsStream("config.properties");));
 
               //get the property value and print it out
                System.out.println(prop.getProperty("database"));
      System.out.println(prop.getProperty("dbuser"));
      System.out.println(prop.getProperty("dbpassword"));
 
     } catch (IOException ex) {
      ex.printStackTrace();
        }
 
    }
}
 

94 comments:

Anonymous said...

[url=http://www.onlinecasinos.gd]online casino[/url], also known as first-class casinos or Internet casinos, are online versions of illustrious ("chunk and mortar") casinos. Online casinos approve gamblers to deport oneself and wager on casino games philosophy pneuma the Internet.
Online casinos typically enter upon aside on the superstore odds and payback percentages that are comparable to land-based casinos. Some online casinos exhort on higher payback percentages with a take off it slump dabble in shindy games, and some spill the beans the circulate about payout captivate audits on their websites. Assuming that the online casino is using an aptly programmed indefinitely infant up generator, proffer games like blackjack be blessed an established have the qualification in place of edge. The payout cut up after these games are established off non-standard boost to the rules of the game.
Diverse online casinos agreement into portion publicly see or reason their software from companies like Microgaming, Realtime Gaming, Playtech, Worldwide Cunning Technology and CryptoLogic Inc.

Anonymous said...

xanax price the drug xanax use - xanax side effects in elderly

Anonymous said...

buy tramadol online order tramadol online forum - tramadol hcl xr

Anonymous said...

buy tramadol online buy cheap tramadol online - cheap tramadol usa

Anonymous said...

generic xanax xanax side effects dizziness - overdose from xanax

Anonymous said...

generic xanax xanax online illegal - xanax withdrawal can't sleep

Anonymous said...

buy tramadol online tramadol for dogs on empty stomach - tramadol no prescription needed

Anonymous said...

xanax online xanax 2mg online no prescription - generic xanax 3 mg

Anonymous said...

buy tramadol online buy tramadol online legit - is it legal to buy tramadol online usa

Anonymous said...

generic xanax xanax side effects alcohol - high on xanax bars

Anonymous said...

buy tramadol online tramadol dose for 40 lb dog - tramadol overnight cod delivery

Anonymous said...

buy tramadol online tramadol 100mg online overnight - cheap tramadol 180

Anonymous said...

buy tramadol online no prescription tramadol overdose dosage - tramadol side effects 50mg

Anonymous said...

xanax online xanax 7.5mg - buy xanax uk no prescription

Anonymous said...

buy tramadol online buy tramadol visa - tramadol dose vet

Anonymous said...

alprazolam xanax xanax and alcohol use - xanax generic pill identification

Anonymous said...

buy tramadol online tramadol 50 mg sleep - buy tramadol online safe

Anonymous said...

buy tramadol online can dog overdose tramadol - buy-cheap-tramadol.org

Anonymous said...

buy tramadol online buy tramadol cash delivery - buy tramadol online cod overnight

Anonymous said...

xanax online death by xanax overdose - xanax side effects webmd

Anonymous said...

xanax online eastbound down quotes xanax - xanax overdose wiki

Anonymous said...

xanax online xanax high liver enzymes - xanax withdrawal with klonopin

Anonymous said...

buy tramadol online tramadol withdrawal day 4 - buy tramadol online echeck

Anonymous said...

buy tramadol online buy tramadol usa pharmacy - buy tramadol cod free

Anonymous said...

generic xanax what is the generic of xanax - buy upjohn xanax online

Anonymous said...

buy tramadol online tramadol withdrawal many days - purchase tramadol

Anonymous said...

generic xanax 0.5 mg xanax effects - 2mg xanax high

Anonymous said...

soma carisoprodol is carisoprodol 350 mg a narcotic - carisoprodol online cod

Anonymous said...

alprazolam price xanax online ireland - purchase xanax online no prescription

Anonymous said...

carisoprodol 350 mg soma carisoprodol tablets 250mg - somacid 350 mg carisoprodol

Anonymous said...

generic tramadol buy tramadol online overnight shipping - order tramadol online mastercard

Anonymous said...

buy tramadol online tramadol kidney failure - long term tramadol addiction

Anonymous said...

carisoprodol 350 mg soma carisoprodol no prescription - carisoprodol 350 mg effects

Anonymous said...

buy tramadol online cheap tramadol pay us - cheap tramadol online cod

Anonymous said...

buy tramadol online ultram er vs tramadol - generic brand name tramadol

Anonymous said...

cialis online cialis free trial online - generic cialis soft tabs

Anonymous said...

order tramadol cheap tramadol line - buy tramadol online from usa

Anonymous said...

buy generic xanax xanax side effects stopping - 2mg xanax first time

Anonymous said...

buy cialis generic buy cialis soft tabs - cialis online rx

Anonymous said...

buy tramadol online tramadol no prescription overnight cod delivery - what does a generic tramadol look like

Anonymous said...

order cialis online cheap cialis overnight no prescription - cialis reviews for bph

Anonymous said...

buy generic cialis cialis rash - buy cialis super active online

Anonymous said...

xanax online generic xanax same xanax - there generic xanax

Anonymous said...

cialis online cialis online prescription order - cialis price at cvs

Anonymous said...

order xanax no prescription what xanax pills look like - xanax viagra drug interactions

Anonymous said...

generic xanax xanax bars drug test - alprazolam 0.5 mg tablet side effects

Anonymous said...

cheap tadalafil buy cialis online new zealand - buy cheap brand cialis

Anonymous said...

buy cialis online order cialis usa - buy cialis 5 mg online

Anonymous said...

xanax online side effects alprazolam 0.5 mg - how long xanax high last

Anonymous said...

cheapest cialis how to buy cialis in us - cialis 5mg online australia

Anonymous said...

cialis online cialis daily or 36 hour - price viagra versus cialis

Anonymous said...

http://landvoicelearning.com/#30896 generic tramadol online no prescription - buy tramadol for dogs

Anonymous said...

buy generic tramadol tramadol (ultram) 50 mg tablet - tramadol generic for ultram

Anonymous said...

http://landvoicelearning.com/#21906 tramadol toothache - tramadol hcl side effects 50mg

Anonymous said...

http://landvoicelearning.com/#21906 tramadol withdrawal oxycontin - tramadol hcl paracetamol

Anonymous said...

best buy tramadol tramadol hcl 50 mg vs oxycodone - buy discount tramadol

Anonymous said...

http://landvoicelearning.com/#38471 tramadol help vicodin withdrawal - tramadol 50 mg opiate

Anonymous said...

tramadol overnight shipping tramadol no prescription free shipping - tramadol dosage australia

Anonymous said...

legal buy tramadol online tramadol hcl 50mg dosage - tramadol withdrawal canine

Anonymous said...

buy tramadol tramadol 50mg usage - 8 50 mg tramadol

Anonymous said...

buy cheap tramadol tramadol order online tramadol 50g - tramadol compared to ultram

Anonymous said...

buy tramadol cheap tramadol 50mg capsules - buy tramadol online no prescription usa

Anonymous said...

We ωant the mаgic pill that inѕtantlу
fixes ргοblems that haѵe takеn
us yeaгs to crеate. Τhere are
certain сhemicalѕ and hormonеs involved
іn increasing the blood flοw to the pеnis.
It only takеѕ а mοderate amount of exercіse and Ereсtile Dyѕfunction
can be overcomе withοut the use of drugs.

Τaκe a look at my web site cialis and alcohol medication
Also see my webpage: mixing cialis and alcohol

Anonymous said...

buy tramadol tramadol no prescription us pharmacy - buy tramadol usa pharmacy

Anonymous said...

http://buytramadolonlinecool.com/#56411 order tramadol overnight cod - tramadol for dogs nausea

Anonymous said...

buy tramadol tramadol hydrochloride 50mg overdose - tramadol no prior prescription

Anonymous said...

http://landvoicelearning.com/#44827 tramadol for dogs euthanasia - 100mg tramadol is equivalent to what

Anonymous said...

buy tramadol online buy tramadol 100mg online - tramadol for dogs ok for people

Anonymous said...

buy tramadol tramadol 50 mg espanol - tramadol 50mg vs 100mg

Anonymous said...

buy tramadol tramadol 50 mg webmd - tramadol online pharmacy

Anonymous said...

http://landvoicelearning.com/#23561 legal buy tramadol online usa - buy tramadol online mastercard overnight

Anonymous said...

buy tramadol online can you buy tramadol online in usa - tramadol hcl abuse

Anonymous said...

learn how to buy tramdadol next day tramadol review - sniffing tramadol high

Anonymous said...

buy ativan online how quickly does ativan work - ativan uses for the elderly

Anonymous said...

buy tramadol tablets buy tramadol online usa - tramadol dosage paracetamol

Anonymous said...

http://reidmoody.com/#45570 ativan prolonged qt interval - ativan dosage levels

Anonymous said...

http://blog.dawn.com/dblog/buy/#40751 tramadol hcl 50 mg tablet - buy tramadol cod overnight delivery

Anonymous said...

tramadol 50 mg tramadol 200 mg get high - buy tramadol online overnight

Anonymous said...

ways to buy ativan online interaction of ativan and alcohol - ativan wiki

Anonymous said...

lorazepam drug buy lorazepam sublinguale - lorazepam 1 mg mylan

Anonymous said...

http://reidmoody.com/#45570 order ativan canada - ativan dosage amounts

Anonymous said...

http://ranchodelastortugas.com/#58720 xanax-effects.com - xanax joint and muscle pain

Anonymous said...

http://ranchodelastortugas.com/#93851 xanax side effects in women - xanax xr generic

Anonymous said...

http://staam.org/#90873 tramadol hcl 50 mg a narcotic - buyer tramadol online

Anonymous said...

oZzy moved away ever before, I miss his cock, and i am always hungry for intercourse.

FUCK MY PUSSY!

Here is my webpage hcg injections
my site :: hcg injections

Anonymous said...

This web site really has all the info I neеded concеrning
this subject аnd didn't know who to ask.

Stop by my web blog; steroids and athletes
my web page: buy injectable steroids

Anonymous said...

http://staam.org/#41652 buy tramadol online overnight delivery - tramadol 50 mg and naproxen

Anonymous said...

alprazolam cheap xanax prescription - klonopin generic xanax

Anonymous said...

I blog often and I genuinely appreciate your content.
The article has truly peaked my interest. I am going
to take a note of your website and keep checking for new
details about once per week. I opted in for your RSS
feed too.

My web blog: cheap mac makeup

Anonymous said...

I believe this is among the so much important information for
me. And i am satisfied reading your article. However wanna observation on
few normal things, The site style is great, the articles is really nice
: D. Excellent activity, cheers

Here is my web-site; cheap ray ban wayfarer

Anonymous said...

Hmm is anyone else encountering problems with the images on this blog loading?
I'm trying to figure out if its a problem on my end or if it's the blog.
Any suggestions would be greatly appreciated.


Feel free to surf to my web site - cheap mac cosmetics

Anonymous said...

Excellent article. Keep writing such kind of info
on your page. Im really impressed by your site.
Hello there, You've done a great job. I'll definitely digg it and individually suggest to my friends.
I am sure they will be benefited from this site.

My web page; wholesale oakley sunglasses

Anonymous said...

Τhis іs rеally іnterеsting, You
are a verу skilled blοggeг.
I have joined your гѕs fеed and look forwаrd to seeking
more of yοur fantastic рοst. Also, I
haѵе shared your site іn my social networks!


my web blog: hcg weight loss scam

Anonymous said...

Hi there, Ι think your ωеbsite could be having browser
compatibility problems. Whenevеr I take а
look at youг blog in Safaгі,
it looks finе however, when оpening in I.
E., it's got some overlapping issues. I just wanted to give you a quick heads up! Other than that, great site!

Here is my web site ... hcg drops diet