This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 1357
    
  19

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: 7551
    
  36

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: 1357
    
  19

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

Joined: Jan 10, 2002
Posts: 63349
    
  70

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: 7551
    
  36

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: 1357
    
  19

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: 63349
    
  70

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

Joined: Apr 18, 2013
Posts: 1357
    
  19

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: 19747
    
  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 agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read .properties file
 
It's not a secret anymore!