System.out to string [duplicate]
问题 This question already has answers here : Redirect console output to string in Java (2 answers) Closed 1 year ago . I have an application that runs through the windows command line, and I want to be able to copy all of the data that has been sent to the console and append it to a file for debugging purposes. Whenever an exception happens, a report is saved to the file system that includes the exception stack trace and the full console. I cannot redirect the entire console to my file because I