Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Unable to redirect all the eclipse console logs to buffer

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Unable to redirect all the eclipse console logs to buffer

    I need to assert some string present in the console logs. I tried the below code to redirect the console logs to buffer. However, still some part of the code goes to console logs and I am unable to assert it programatically. Could someone help me here ?

    System.setOut( new PrintStream(new ByteArrayOutputStream()));


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Unable to redirect all the eclipse console logs to buffer

    Assertions and exceptions are sent to the Error stream, so if you are looking to assert these you should also set the error stream:
    System.setErr( new PrintStream(new ByteArrayOutputStream()));

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Unable to redirect all the eclipse console logs to buffer

    Thanks a lot.

Similar Threads

  1. Replies: 24
    Last Post: August 4th, 2014, 12:49 PM
  2. The Bounded Buffer Problem
    By skatescholar in forum Java Theory & Questions
    Replies: 0
    Last Post: April 8th, 2010, 11:22 AM
  3. Changing output from console to .html
    By RSYR in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: December 10th, 2009, 07:55 PM
  4. [SOLVED] help with console input strnig....
    By mdstrauss in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: August 17th, 2009, 03:59 AM
  5. Redirect error and output stream using java program
    By leenabora in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: June 16th, 2009, 04:12 AM