Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading Properties file in Jython

 
Jacob John
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my jython script i want to read a properties file like.

import java.util as util
import java.io as javaio

properties = util.Properties
#add try catch for this
propertiesfis =javaio.FileInputStream("wasconfig.properties")
properties.load( propertiesfis)

While running this script its showing the error

File "<string>", line 19, in ?
TypeError: load(): expected 2 args; got 1

But the java syntax for java.util.Properties.load() takes only one parameter. So what else jython is expecting here?

Can any one help me in this. Thanks in advance.

Regards
Jacob
 
Jacob John
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This got corrected. I had to use properties = util.Properties() instead of properties = util.Properties
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, that makes sense. The util.Properties would be a reference to Properties.class rather than instantiating an instance of the Properties class.

Thanks for updating with the solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic