What is the point of not having to close an InputStream after it's finished?

InputStreamimplements Closeable.

I understand that closing the InputStream , which has not yet ended , may make sense to free some basic resources, and leaving it open, it may make sense to allow other methods to continue reading from it.

But what sense it can be not to close InputStream after it ?
And if that doesn't make sense, why reaching the end of InpuntStream doesn't mean closing then?

The same question applies to Reader.

+5
source share
7 answers

mark() reset() "" .

, lookahead.

+9

org.life.java

, : InputStream ()?

. , , , , .

, ( ):

InputStream stream = openMethod( );

try
{
   consumeMethod( stream );
}
finally
{
   stream.close( );
}

, , .

+3

Windows . , .

+3

mark() reset() InputStream. , , , . -, reset() InputStream, .

+1

, InputStream java, , , ( ), . , .

0

,

  • , , ( , ), . , , .
  • (mark/ reset).
0

API- InputStream, , .. . , , .

0

All Articles