Reputation: 101
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?
Upvotes: 1
Views: 410
Reputation: 75545
Run your program like this:
java Program > /dev/null
On Windows, you can do this instead.
java Program >NUL
Upvotes: 1
Reputation: 235984
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.
Upvotes: 3