V
V
Volodar Znatsky2016-11-02 08:27:15
Java
Volodar Znatsky, 2016-11-02 08:27:15

How to get all console output into a variable on completion?

There is a console program. We enter text into the console - the program displays its own text. Upon completion of the work, I would like to intercept all the text output by the program for the entire time of work and save it to a file. Whether it is possible to execute such obtaining of the text?
You can, of course, change the operation a bit:
text += "This will appear on the screen";
out println(text);
But if the program has 2000 lines? Lot! I don't want to do this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vorh, 2016-11-02
@Vorh

The easiest option at startup is to specify the file in which all the information output by the program will be displayed:
Or configure the output in the code:
But it is much better to choose one of the logging libraries Log4J, LogBack , etc. or built-in by default in java java.util.logging - understand them and customize them for yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question