In Java, how can I find the name of the stream that is passed as an argument if the given stream is either System.err or System.out ?
public String getStreamName(OutputStream arg0) { String streamName = ????; return "This is stream: " + streamName; }
should return something like:
This is stream: System.err
I tried arg0.toString() , but this does not seem useful, since the return name is something like java.io.PrintStream@71cb25 and changes every time it starts. If the name was fixed, I could just compare it with the famous names for stdout and stderr.
source share