java.io.FileInputStream.finalize()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中java.io.FileInputStream.finalize()方法的一些代码示例,展示了FileInputStream.finalize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileInputStream.finalize()方法的具体详情如下:
包路径:java.io.FileInputStream
类名称:FileInputStream
方法名:finalize

FileInputStream.finalize介绍

[英]Ensures that all resources for this stream are released when it is about to be garbage collected.
[中]确保在即将进行垃圾收集时释放此流的所有资源。

代码示例

代码示例来源:origin: geoserver/geoserver

@Override
  protected void finalize() throws IOException {
    if (!closed) {
      String warn =
          "There is code leaving resource input streams open, locks around them might not be cleared! ";
      if (!TRACE_ENABLED) {
        warn +=
            "Add -D"
                + GS_LOCK_TRACE
                + "=true to your JVM options to get a full stack trace of the code that acquired the input stream";
      }
      LOGGER.warning(warn);
      if (TRACE_ENABLED) {
        LOGGER.log(
            Level.WARNING,
            "The unclosed input stream originated on this stack trace",
            tracer);
      }
    }
    super.finalize();
  }
};

代码示例来源:origin: org.postgresql/postgresql

protected void finalize() throws IOException {
  // forcibly close it because super.finalize() may keep the FD open, which may prevent
  // file deletion
  close();
  super.finalize();
 }
};

相关文章