aspose file tools
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 1Z0-808 this week in the OCAJP 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: 1072
    
  17

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


OCPJP 6, OCPJP 7, OCMJD 6
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5839
    
  17

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: 1072
    
  17

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

Joined: Jan 10, 2002
Posts: 61961
    
  67

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
Bartender

Joined: Jul 19, 2004
Posts: 5839
    
  17

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: 1072
    
  17

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: 61961
    
  67

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

Joined: Apr 18, 2013
Posts: 1072
    
  17

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
Bartender

Joined: Oct 14, 2005
Posts: 19097
    
    8

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.
 
jQuery in Action, 2nd edition
 
subject: How to read .properties file