File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 1104
    
  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
Sheriff

Joined: Jul 19, 2004
Posts: 6565
    
  24

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

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

Joined: Jan 10, 2002
Posts: 62469
    
  68

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: 6565
    
  24

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: 1104
    
  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: 62469
    
  68

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

Joined: Apr 18, 2013
Posts: 1104
    
  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
Sheriff

Joined: Oct 14, 2005
Posts: 19413
    
  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