need a mechanism for turning ON/OFF SOPs

hi all,

please help me in finding a solution::: the scenario is I have some 20

classes and each has 2 methods and those methods has

System.out.println(" some text "). i need a mechanism to turn ON/ OFF

the SOPs to be printed in the console.

I have two possible ways

1. using javaw instead of java which will bypass the console.

2. using an if condition

for eg:[

class A

{

boolean a =false;

if(false)

{

System.out.println("some text");

}

}

but I need to have this IF condition check at each n every method is

there any possibility that I can have only one check that can turn

ON /OFF the SOPs

or please help me with other alternatives.

thanks in advance

[1081 byte] By [coolsnipstera] at [2007-11-27 1:49:28]
# 1

You can set the stream that System.out represents with System.setOut(PrintStream). Of course this will affect all output made via System.out.println().

Alternatively you could use our own PrintStream rather than System.out.

(If this is logging information you could use an existing logging framework and not reinvent the wheel.)

pbrockway2a at 2007-7-12 1:14:47 > top of Java-index,Java Essentials,Java Programming...
# 2

Or just use a small class rather than create your own PrintStream:public class Outputter {

private static boolean enabled;

public static void setEnabled(boolean b) {

enabled = b;

}

public static void println(String s) {

if(enabled) System.out.println(s);

}

}

pbrockway2a at 2007-7-12 1:14:47 > top of Java-index,Java Essentials,Java Programming...
# 3
Nice star there, pbrockway2. ;-)
CaptainMorgan08a at 2007-7-12 1:14:48 > top of Java-index,Java Essentials,Java Programming...
# 4
> Nice star there, pbrockway2. ;-)Thanks - it sort of crept up on me. The next lap seems rather long...
pbrockway2a at 2007-7-12 1:14:48 > top of Java-index,Java Essentials,Java Programming...