Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: Is it possible to capture println data inside variable?

  1. #1
    africanhacker is offline Senior Member
    Join Date
    Feb 2011
    Posts
    107
    Rep Power
    0

    Default 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.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Is it possible to capture println data inside variable?

    Sure, write your own printstream and use System.setOut
    System (Java Platform SE 6)
    africanhacker likes this.

  3. #3
    africanhacker is offline Senior Member
    Join Date
    Feb 2011
    Posts
    107
    Rep Power
    0

    Default Re: Is it possible to capture println data inside variable?

    Quote Originally Posted by eRaaaa View Post
    Sure, write your own printstream and use System.setOut
    System (Java Platform SE 6)
    Many thanks to you

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default 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
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Using JSTL to capture HTTP referer data and serialize into a variable
    By jeremy.wilson in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 05-19-2011, 12:44 PM
  2. replace inside the println
    By javauserjava in forum New To Java
    Replies: 24
    Last Post: 04-06-2011, 01:12 AM
  3. how to capture jsf form data
    By Srikala in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 07-16-2009, 09:06 AM
  4. Help require to capture streaming data
    By jobseeker in forum Java Servlet
    Replies: 1
    Last Post: 04-02-2009, 09:18 PM
  5. println doesn't print from inside for loop, et.al.
    By rdtindsm in forum New To Java
    Replies: 5
    Last Post: 03-27-2009, 01:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •