Example usage for java.io PrintStream flush

List of usage examples for java.io PrintStream flush

Introduction

In this page you can find the example usage for java.io PrintStream flush.

Prototype

public void flush() 

Source Link

Document

Flushes the stream.

Usage

From source file:Main.java

public static void main(String[] args) {
    float x = 1.23f;

    PrintStream ps = new PrintStream(System.out);

    // print float
    ps.print(x);//from   w  w  w  . java2s. c o m

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    double x = 12345678;

    PrintStream ps = new PrintStream(System.out);

    // print double
    ps.print(x);/*from w ww .  j a v a2s .c  o  m*/

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    byte c[] = { 70, 71, 72, 73, 74, 75, 76 };

    PrintStream ps = new PrintStream(System.out);

    // write bytes 1-3
    ps.write(c, 1, 3);//from  w  ww . j a v a 2s  .c  om

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    long x = 1234567890l;
    try {//from   w  ww.j  a v a2s.  c  o  m

        PrintStream ps = new PrintStream(System.out);

        // print long
        ps.print(x);

        // flush the stream
        ps.flush();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    char c = 'a';

    PrintStream ps = new PrintStream(System.out);

    // print char
    ps.print(c);//from   w  ww. jav a  2s . c o m
    ps.print('b');

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    int x = 123;//ww  w.  j  av  a2 s  . co m

    PrintStream ps = new PrintStream(System.out);

    // print integer
    ps.print(x);
    ps.print(100);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    Object x = 50;/*from  w  w  w  . j a va 2s  . c  o m*/
    Object s = "from java2s.com";

    PrintStream ps = new PrintStream(System.out);

    // print objects
    ps.print(x);
    ps.print(s);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    String s = "from java2s.com";

    PrintStream ps = new PrintStream(System.out);

    // format a string
    ps.format("This is a %s program", s);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    char[] s = { 'a', 'b', 'c' };
    char[] c = { 'H', 'e', 'l', 'l', 'o' };

    PrintStream ps = new PrintStream(System.out);

    // print char array
    ps.print(s);/*w w w.j a  v  a  2s  .  co  m*/
    ps.print(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    boolean bool = false;

    PrintStream ps = new PrintStream(System.out);

    // print boolean
    ps.print(true);/* w ww . j a v a 2  s .  c o m*/
    ps.print(bool);

    // flush the stream
    ps.flush();

}