InputStream.close() 有什么作用吗?
Does InputStream.close() do anything?
public void close()
throws IOException
Closes this input stream and releases any system resources associated with the stream.
The close method of InputStream does nothing.
那么它是什么都不做还是什么都不做?
InputStream
的 close()
方法什么都不做。 InputStream
子类的 close()
方法可以 做一些事情。
不,它什么都不做,但是 InputStream
是一个 abstract
class,其中 close
不是抽象的(它实现了 java.io.Closeable
) ,它有一个空 body。 InputStream
的实现者可以选择覆盖该方法。 FileInputStream
关闭文件输入流并释放任何 ByteInputStream
不执行任何操作的系统资源。
正如@Kayaman 所说,InputStream
是一个抽象的 class 并且 close
方法没有在那里实现。如果你很好奇,你可以看到这个link which sows you close method on java.io.FileInputStream
of openjdk version 8u40-b25, from GrepCode.
public void close() throws IOException
Closes this input stream and releases any system resources associated with the stream.
The close method of InputStream does nothing.
那么它是什么都不做还是什么都不做?
InputStream
的 close()
方法什么都不做。 InputStream
子类的 close()
方法可以 做一些事情。
不,它什么都不做,但是 InputStream
是一个 abstract
class,其中 close
不是抽象的(它实现了 java.io.Closeable
) ,它有一个空 body。 InputStream
的实现者可以选择覆盖该方法。 FileInputStream
关闭文件输入流并释放任何 ByteInputStream
不执行任何操作的系统资源。
正如@Kayaman 所说,InputStream
是一个抽象的 class 并且 close
方法没有在那里实现。如果你很好奇,你可以看到这个link which sows you close method on java.io.FileInputStream
of openjdk version 8u40-b25, from GrepCode.