aspose file tools*
The moose likes Jython/Python and the fly likes Reading Properties file in Jython Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Reading Properties file in Jython" Watch "Reading Properties file in Jython" New topic
Author

Reading Properties file in Jython

Jacob John
Greenhorn

Joined: Jun 21, 2004
Posts: 2
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

Joined: Jun 21, 2004
Posts: 2
This got corrected. I had to use properties = util.Properties() instead of properties = util.Properties
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading Properties file in Jython