Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to read .properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to read .properties file" Watch "How to read .properties file" New topic
Author

How to read .properties file

Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1272
    
  18

How did you read your properties file?
- java.util.Properties.load(java.io.Reader) ?
- just usual file read line by line?


OCPJP 6, 7, 8, OCMJD 6
Roel De Nijs
Sheriff

Joined: Jul 19, 2004
Posts: 7230
    
  29

Why would you read and parse a properties file yourself, if you have an API (class) available which does this work for you. No need to reinvent the wheel!


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
OCAJP 7
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1272
    
  18

Because reading couple lines of text is very simple wheel to reinvent ;) ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63202
    
  69

Pawel Pawlowicz wrote:Because reading couple lines of text is very simple wheel to reinvent ;) ?


Worst. Reason. Ever.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Roel De Nijs
Sheriff

Joined: Jul 19, 2004
Posts: 7230
    
  29

That's not only a bad reason, it might (and probably will) result in point loss (not using/ knowing the Java API).
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1272
    
  18

Bear Bibeault wrote:
Pawel Pawlowicz wrote:Because reading couple lines of text is very simple wheel to reinvent ;) ?


Worst. Reason. Ever.
Yes, I could agree that this is a bad reason. But Worst. Reason. Ever.? That I don't get.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63202
    
  69

"Because I can" is the worst possible reason to not use the existing API.
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 1272
    
  18

Bear Bibeault wrote:"Because I can" is the worst possible reason to not use the existing API.
If you put it that way, I completely agree .
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19720
    
  10

Reason: because somebody might read about all of the strange ways to put data into a properties file, and then find out the hard way that your quick and dirty properties file parser didn't bother to implement all of those features.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How to read .properties file
 
jQuery in Action, 3rd edition