• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Property Values from Properties.Load()  RSS feed

 
Valerie Pooh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to get the property values after using Properties.load("aaa.types") method. An example of aaa.types content:



What i actually want to do is to search the property name using the property value. The file is stored this way and so i won't be able to change it around. If anyone has any suggestions please let me know, thanks.
[ October 26, 2007: Message edited by: Valerie Pooh ]
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Properties extends Hashtable<Object,Object>, so Properties is also a Map<Object,Object>:

Unfortunately, the Java developers thought it was more important to protect old code abusing the fact that Properties is a Hashtable than protect Properties against invalid insertions. Therefore, instead of being a Hashtable<String,String> as you'd expect, they made it a Hashtable<Object,Object>. Therefore, you'd still have to check if the key and values are actually strings.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your file ever have more than one file extension for the same MIME type? For example:

If this ever happens, you shouldn't use Properties at all, as it will lose some of your data. Instead just read the file line by line, split() each line into two parts, and put each line into a Map<String, String>, making sure that the key is the file extension, which must be unique, and the MIME times is the value, which need not be unique. This will also allow you to easily look up MIME type by file type.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!