This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a properties file using BufferdInputStream  RSS feed

 
kalig priya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to read a properties file using BufferedInputStream...

BufferedInputStream bufferedinputstream =new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(s));

I'm getting "InputStream Closed" exception.

Can any one help me in resolving this issue.
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, kalig
It's a good idea to separate the obtaining of the resource and the creation of the input stream. That way you can test the return value of getResourceAsStream() to make sure you've found the resource in question before attempting to read it.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the subject says : Reading a properties file using BufferdInputStream.

I am assuming that you are trying to read a properties file.In that case you case create a FileInputStream and then using the load method of Properties object you can load it.

FileInputStream fin = ..
Properties p = new Properties();
p.load(fin);
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!