javaopentsdbsystem.in

In which case should I use System.in.close()?


when I am reading the code of opentsdb:

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

After searching this question on the Internet, I can't find a suitable answer. I don't understand why they write system.in.close(), and I want to know if we don't add this code block, what will happen?


Solution

  • Probably only if you used System.setIn() to override the standard input. One normally does not close the standard input, it's handled by JVM process shutdown.