*
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: 842
    
  14

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


Formely Pawel Pawlowicz
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5131
    
  12

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
http://www.javaroe.be/
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 842
    
  14

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

Joined: Jan 10, 2002
Posts: 60782
    
  65

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: 5131
    
  12

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: 842
    
  14

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: 60782
    
  65

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

Joined: Apr 18, 2013
Posts: 842
    
  14

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: 18541
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read .properties file
 
Similar Threads
Read duplicate keys from properties file
Reading properties from another properties file.
Java property files best practices
Thread Creation at runtime.
Regarding reading a property file