java - 在什么情况下我应该使用System.in.close()?

标签 java opentsdb system.in

当我阅读opentsdb的代码时:

try {
    System.in.close();  // Release a FD we don't need.
} catch (Exception e) {
    log.warn("Failed to close stdin", e);
}

在网上搜索这个问题后,没有找到合适的答案。我不明白他们为什么要写system.in.close(),我想知道如果我们不添加这个代码块,会发生什么?

最佳答案

可能仅当您使用System.setIn()时覆盖标准输入。通常不会关闭标准输入,而是由 JVM 进程关闭来处理。

关于java - 在什么情况下我应该使用System.in.close()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55264878/

相关文章:

java - 为什么连接终止时不抛出异常?

java - 保持输出而不打印直到程序终止

hadoop - hbase 找不到现有表

java - System.in 是如何工作的?

java - 在Java控制台中输入字符串时出现"input line is too long"

java - 我是否需要在实现 MessageListener 类的类的 onMessage 方法中关闭执行器?

java - Spring Security @Secured注解和Scala Controller

hadoop - OpenTSDB 与 kerberized HBase 集成

java.lang.NoClassDefFoundError : Could not initialize class org. apache.hadoop.hbase.shaded.protobuf.ProtobufUtil$ClassLoaderHolder 错误

Netty客户端的Java输入