Code Examples
A repository of 155 code examples for BeepBeep
io.PrintStdout Class Reference

Print events to the standard input. More...

Static Public Member Functions

static void main (String[] args) throws InterruptedException
 

Detailed Description

Print events to the standard input.

In this simple example, we push numbers 0 to 4 at one-second intervals. The expected output of this program should be:

0,1,2,3,4,

The processor chain of this example is very simple, and consists of a single processor:

Processor graph

Let us use this program from the command-line. Suppose you compile this program into a runnable JAR file called

printstdout.jar

. You can then run this program like any other Java JAR as follows:

$ java -jar printstdout.jar

However, since this program writes to the standard output, you can redirect it to a file like any other program too. For example, writing this to the command line will redirect ("pipe") the output to a file called

my-file.txt

:

$ java -jar printstdout.jar > my-file.txt

Since the output events are produced at the rate of one per second, it will take five seconds for the file to be written. If you try to open it before (for example, in a text editor), you will only see the events that have been pushed to it so far.

The output can be redirected to other programs as well; for example, to redirect the output to the wc command to count the number of characters in the output:

$ java -jar printstdout.jar | wc -m

Here, the standard output of the Java program is redirected into the standard input of the

wc

command.

Author
Sylvain Hallé Easy

Definition at line 67 of file PrintStdout.java.


The documentation for this class was generated from the following file: