Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read .properties file

 
Paweł Baczyński
Bartender
Posts: 1762
33
Firefox Browser IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you read your properties file?
- java.util.Properties.load(java.io.Reader) ?
- just usual file read line by line?
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Paweł Baczyński
Bartender
Posts: 1762
33
Firefox Browser IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because reading couple lines of text is very simple wheel to reinvent ;) ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Because reading couple lines of text is very simple wheel to reinvent ;) ?


Worst. Reason. Ever.
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1762
33
Firefox Browser IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Because I can" is the worst possible reason to not use the existing API.
 
Paweł Baczyński
Bartender
Posts: 1762
33
Firefox Browser IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20969
31
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic