1

I have code that uses system.out.println to print out an array of string objects. These string objects are then saved to a text file. Everything works great with the program but when the program is compiling the system.out.println prints all of the strings to the console. Is there anyway I can make it so that the user does not see what the system.out.println produces when I save a file?

1
  • 2
    use logging such as log4j and use debug/log in place of System.out. Commented Apr 9, 2014 at 20:48

2 Answers 2

3

Remove all the System.out.println() calls and replace them with a call to a logger (for example, log4J). Then, you can globally turn on/off logging in your application or set different logging levels using configuration files. In general, it's a bad idea to leave System.out.println() calls in production code, that's what loggers are for.

Sign up to request clarification or add additional context in comments.

Comments

1

Run your program like this:

java Program > /dev/null 

On Windows, you can do this instead.

java Program >NUL 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.