Example usage for java.io PrintStream PrintStream

List of usage examples for java.io PrintStream PrintStream

Introduction

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

Prototype

public PrintStream(File file) throws FileNotFoundException 

Source Link

Document

Creates a new print stream, without automatic line flushing, with the specified file.

Usage

From source file:Main.java

public static void main(String[] args) {

    PrintStream ps = new PrintStream(System.out);

    // print a boolean and change line
    ps.println(true);/*from  w w w. j  av a  2  s.  c  om*/
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {

    PrintStream ps = new PrintStream(System.out);

    // print this string
    ps.print("This is a String");

    // print new line
    ps.println();/*from  www  .  j a v a2s .co  m*/

    // print a new string
    ps.println("from java2s.com");

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    byte c = 70;//from  www  .  j  a  v a  2s  .c  om

    PrintStream ps = new PrintStream(System.out);

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    int x = 123;//from  ww  w . j  av a 2  s . c  om

    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) {
    int c = 123;//from ww  w  .j  ava2 s  .c om

    PrintStream ps = new PrintStream(System.out);

    // print an integer and change line
    ps.println(c);
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

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  www  . j  a va2 s  .  c o m
    ps.print('b');

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    Object c = 15;// w ww .ja  v  a  2 s  .co m

    PrintStream ps = new PrintStream(System.out);

    // print an object and change line
    ps.println(c);
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

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);/* w w  w  .ja  v  a  2s.co m*/

    // flush the stream
    ps.flush();

}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // print a char and change line
    ps.println(c);/*from ww  w  .j av a 2 s  .c  o m*/
    ps.println('b');
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // append our characters
    ps.append(c);//from  ww  w.  j  a va 2 s .  co  m
    ps.append('y');
    ps.append('m');

    // print the result
    ps.flush();
    ps.close();

}