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) {
    double x = 12345678;

    PrintStream ps = new PrintStream(System.out);

    // print double
    ps.print(x);/*  w w  w. j  a  va2s  .  c  om*/

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    double c = 12345.56;

    PrintStream ps = new PrintStream(System.out);

    // print a double and change line
    ps.println(c);/*from  w w w .  j  a  va2  s  . c om*/
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    float c = 1.234567f;

    PrintStream ps = new PrintStream(System.out);

    // print a float and change line
    ps.println(c);/*from  w w  w  .  j  a va2 s. c o m*/
    ps.print("from java2s.com");

    // 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);//from  ww  w. j  av  a  2 s .c om
    ps.print(bool);

    // 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);

    // printf this string
    ps.printf("This is a %s application", s);

    // flush the stream
    ps.flush();//from   ww  w.  j av a2s. c  o m

}

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  w  ww .j a v  a 2  s . c  om*/

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    System.setOut(new PrintStream(new FileOutputStream("system_out.txt")));
    System.out.println("sent to the file system_out.txt");
}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // print string
    ps.print(s);/*  ww w .  java  2 s .c  om*/
    ps.print(" This is an example");

    // flush the stream
    ps.flush();

}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // print a string and change line
    ps.println(c);//from   w w w .  j  a v a2 s .  co m
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // print an array and change line
    ps.println(c);//from w w w  .  j ava2 s.com
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}