Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a properties file using BufferdInputStream

 
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: 9362
11
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);
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!