Is it possible to capture println data inside variable?
I am working on some very clunky code that someone else has written. For some reason they decided to write all their functions as void, none of them return anything. Instead she was using println very often.
Is there a way I can capture the data being outputted by println? I wan to display this data in a GUI which is why I need this in String not print.
Many thanks in advance.
Re: Is it possible to capture println data inside variable?
Sure, write your own printstream and use System.setOut
System (Java Platform SE 6)
Re: Is it possible to capture println data inside variable?
Quote:
Originally Posted by
eRaaaa
Many thanks to you
Re: Is it possible to capture println data inside variable?
That may provide a workable short-term solution, but it's exceedingly brittle. Far better to rewrite or add methods that return meaningful values -- a Model -- and redevelop the app on MVC lines.
db