Have you ever seen a Java File close() throw an exception?

前端 未结 8 908
野性不改
野性不改 2020-12-31 00:10

Has anyone ever seen an exception thrown when calling close method on any closable object?

8条回答
  •  误落风尘
    2020-12-31 00:20

    I haven't, but it's possible. Imagine if there's an OutputStream that for some reason hasn't written to the file yet. Well, calling close() will flush out the data, but if the file is locked - then an IOException would be raised.

提交回复
热议问题