Example usage for java.lang System setOut

List of usage examples for java.lang System setOut

Introduction

In this page you can find the example usage for java.lang System setOut.

Prototype

public static void setOut(PrintStream out) 

Source Link

Document

Reassigns the "standard" output stream.

Usage

From source file:org.apache.tika.cli.TikaCLIBatchIntegrationTest.java

@Before
public void setup() throws Exception {
    tempOutputDir = Files.createTempDirectory("tika-cli-test-batch-");
    outBuffer = new ByteArrayOutputStream();
    PrintStream outWriter = new PrintStream(outBuffer, true, UTF_8.name());
    ByteArrayOutputStream errBuffer = new ByteArrayOutputStream();
    PrintStream errWriter = new PrintStream(errBuffer, true, UTF_8.name());
    out = System.out;/*from ww  w .j a  v  a 2 s. c o  m*/
    err = System.err;
    System.setOut(outWriter);
    System.setErr(errWriter);
    testInputDirForCommandLine = testInputDir.toAbsolutePath().toString();
    tempOutputDirForCommandLine = tempOutputDir.toAbsolutePath().toString();
}

From source file:org.g_node.mergers.LktCliControllerTest.java

/**
 * Reset Out stream to the console after the tests are done.
 * @throws Exception//from  ww w .  j  ava  2s .  co m
 */
@After
public void tearDown() throws Exception {
    System.setOut(this.stdout);

    if (Files.exists(this.testFileFolder)) {
        FileUtils.deleteDirectory(this.testFileFolder.toFile());
    }
}

From source file:de.langmi.spring.batch.tutorials.helloworld.HelloWorldJobConfigurationManualTest.java

@After
public void cleanUpStreams() {
    // reset JVM standard
    System.setOut(null);
}

From source file:flow.visibility.tapping.OpenDayLightUtils.java

/** Creating the Pane for Flow Entry */

public OpenDayLightUtils() {
    super("Installed Flow");

    FlowtextArea = new JTextArea(50, 10);
    FlowtextArea.setEditable(false);/*from   w  w w .  j a  v  a  2 s  . c  om*/
    FlowtextArea.setFont(new Font("Courier New", Font.BOLD, 12));
    PrintStream FlowprintStream = new PrintStream(new CustomOutputStream(FlowtextArea));

    // re-assigns standard output stream and error output stream
    System.setOut(FlowprintStream);
    System.setErr(FlowprintStream);

    // creates the GUI
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.insets = new Insets(10, 10, 10, 10);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;

    /** Adding the Pane into Frame */

    scrollPane = new JScrollPane(FlowtextArea);
    this.add(scrollPane, constraints);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setSize(400, 600);
    setLocationRelativeTo(null); // centers on screen
}

From source file:bridge.toolkit.ControllerJFrame.java

/** Creates new form NewJFrame */
public ControllerJFrame() {
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
    Date date = new Date();

    currentTime = dateFormat.format(date);

    parser = new ConfigParser();
    Controller loader = new Controller();
    sampleCatalog = loader.createCatalog();

    ctx = new ContextBase();
    initComponents();//from w w w . j  a v a 2 s . c o  m
    System.setOut(aPrintStream); // catches System.out messages
    System.setErr(aPrintStream); // catches error messages

}

From source file:com.yahoo.validatar.OutputCaptor.java

public static void redirectToDevNull() {
    System.setOut(NULL);
    System.setErr(NULL);
}

From source file:org.apache.hadoop.util.TestClasspath.java

@After
public void tearDown() {
    System.setOut(oldStdout);
    System.setErr(oldStderr);
    IOUtils.cleanup(LOG, printStdout, printStderr);
    assertTrue(FileUtil.fullyDelete(TEST_DIR));
}

From source file:org.apache.flink.yarn.CliFrontendYarnAddressConfigurationTest.java

@BeforeClass
public static void disableStdOutErr() {
    class NullPrint extends OutputStream {
        @Override//from   www  .  j a  va  2 s  . c  o m
        public void write(int b) {
        }
    }

    PrintStream nullPrinter = new PrintStream(new NullPrint());
    System.setOut(nullPrinter);
    System.setErr(nullPrinter);

    // Unset FLINK_CONF_DIR, as this is a precondition for this test to work properly
    Map<String, String> map = new HashMap<>(System.getenv());
    map.remove(ConfigConstants.ENV_FLINK_CONF_DIR);
    TestBaseUtils.setEnv(map);
}

From source file:com.replaymod.replaystudio.launcher.DaemonLauncher.java

public void launch(CommandLine cmd) throws Exception {
    int threads = Integer.parseInt(cmd.getOptionValue('d', "" + Runtime.getRuntime().availableProcessors()));
    worker = Executors.newFixedThreadPool(threads);

    System.setOut(new PrintStream(systemOut = new ThreadLocalOutputStream(System.out)));
    ServerSocket serverSocket = new ServerSocket(PORT);
    System.out.println("Daemon started on port " + PORT + " with " + threads + " worker threads.");
    while (!Thread.interrupted()) {
        Socket socket = serverSocket.accept();
        try {//from   www .j a va2 s  . c om
            Client client = new Client(socket);
            new Thread(client).start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.eclipse.gemini.blueprint.util.SimpleLoggerTest.java

protected void setUp() throws Exception {
    outStream = new AssertivePrintStream(new NullOutputStream());
    errStream = new AssertivePrintStream(new NullOutputStream());
    System.setErr(errStream);/*  w  w  w  .  jav  a  2  s .c om*/
    System.setOut(outStream);

    simpleLogger = new SimpleLogger();
    object = new Object();
    throwable = new MyThrowable();
}