What are some scenarios in which java\'s System.out.println would fail to produce any output. I have a call to it inside of a method and sometimes when the method is called
It's possible that the file handle has been changed. I.e., stdout
's file descriptor is no longer 1
. I've seen this done in logging utilities where people don't want to go and catch any text that might be printed to a file descriptor, so instead they just redirect the stream to a file handle of an open file.
Here's an example in python:
import sys
h = open(r"C:\foo.txt","a+")
sys.stdout = h
sys.stdout.write("hey fellas")
h.close()
Run this at the cmdline, and you'll not get "hey fellas" printed out as you expect. Instead, it will be redirected to the file C:\foo.txt