www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - InputStream close()?

reply Bradley Smith <digitalmars-com baysmith.com> writes:
Is there some reason why the InputStream interface does not have a 
close() method?

Thanks,
   Bradley
Jun 15 2006
next sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"Bradley Smith" <digitalmars-com baysmith.com> wrote in message 
news:e6stsf$31he$1 digitaldaemon.com...
 Is there some reason why the InputStream interface does not have a close() 
 method?

 Thanks,
   Bradley

I vaguely recalling poking around with adding one but it would conflict with OutputStream's close(). Creating a Closeable interface - this is where I can't remember the details - ended up requiring all Stream classes to be declared as Closeable. Or something like that. It's worth giving it another shot for sure.
Jun 16 2006
parent reply Bradley Smith <digitalmars-com baysmith.com> writes:
Ben Hinkle wrote:
 "Bradley Smith" <digitalmars-com baysmith.com> wrote in message 
 news:e6stsf$31he$1 digitaldaemon.com...
 Is there some reason why the InputStream interface does not have a close() 
 method?

 Thanks,
   Bradley

I vaguely recalling poking around with adding one but it would conflict with OutputStream's close(). Creating a Closeable interface - this is where I can't remember the details - ended up requiring all Stream classes to be declared as Closeable. Or something like that. It's worth giving it another shot for sure.

You can't have two interfaces with the same method? I haven't tried it yet, but since both InputStream and OutputStream are both interfaces, I assumed that it would not cause a conflict. How does one design complex systems if interfaces conflict so easily? Thanks, Bradley
Jun 16 2006
parent "Ben Hinkle" <bhinkle mathworks.com> writes:
"Bradley Smith" <digitalmars-com baysmith.com> wrote in message 
news:e6uiuc$2ngf$1 digitaldaemon.com...
 Ben Hinkle wrote:
 "Bradley Smith" <digitalmars-com baysmith.com> wrote in message 
 news:e6stsf$31he$1 digitaldaemon.com...
 Is there some reason why the InputStream interface does not have a 
 close() method?

 Thanks,
   Bradley

I vaguely recalling poking around with adding one but it would conflict with OutputStream's close(). Creating a Closeable interface - this is where I can't remember the details - ended up requiring all Stream classes to be declared as Closeable. Or something like that. It's worth giving it another shot for sure.

You can't have two interfaces with the same method? I haven't tried it yet, but since both InputStream and OutputStream are both interfaces, I assumed that it would not cause a conflict. How does one design complex systems if interfaces conflict so easily? Thanks, Bradley

I just tried implementing two interfaces with the same member and it seems to work. I don't remember enough about what I tried to provide any help.
Jun 16 2006
prev sibling parent David Medlock <noone nowhere.com> writes:
Bradley Smith wrote:
 Is there some reason why the InputStream interface does not have a 
 close() method?
 
 Thanks,
   Bradley

Some Input streams wouldnt necessarily close. Suppose you had a Decompressing stream over another file stream. You want to close the parent stream. If you are dealing with File InputStreams just use a Stream variable when you create the object: Steam st = new File( "myfile", FileMode.In ); ... st.close(); -DavidM
Jun 16 2006