Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 768557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:12:02+00:00 2026-05-14T18:12:02+00:00

I was doing my academic project and while building and testing i have put

  • 0

I was doing my academic project and while building and testing i have put many println() statements.

But when I had to submit all prints should not be displayed.

Can i implement something like listener which will be invoked when System.out is tried to be executed and prevents it from displaying.
I dont know how feasible this idea is but just want to know whether its possible or not.
I know i could have used a log file or write into a file but again its just a thought came into my mind if I have to disable SOP how can i do it ..

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:12:02+00:00Added an answer on May 14, 2026 at 6:12 pm

    use System.setOut function (and setErr)
    The following program will only print 1: (and not 2)

    public static void main(String[] args) throws FileNotFoundException {
        System.out.println("1");
        System.setOut(new PrintStream(new OutputStream() {
            @Override
            public void write(int arg0) throws IOException {
                // TODO Auto-generated method stub
    
            }
        }));
        System.out.println("2");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a desktop academic project one of the requirment of this project is
Doing a small project I have received some Java code that I should rewrite
This is an academic question (I'm not necessarily planning on doing it) but I
I'm doing an academic project which focus on providing some enhanced LBS services for
I'm currently doing an academic benchmark, TPC-H, and I have some big tables that
I'm doing an academic project and I'm not asking for help, only suggestions for
I am doing an academic project, which involves learning android and i needed to
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing some jquery animation. I have certain divs set up with an attribute of
Doing code analysis of the project and get the message Reference-counted object is used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.