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) throws Exception {
    System.setErr(new PrintStream(new FileOutputStream("system_err.txt")));

    String nullString = null;//from  w ww . j a va2 s .c o  m
    nullString = nullString.toUpperCase();
}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // append our strings
    ps.append(s);// w ww. j a va  2 s . c o  m
    ps.append("This is an example.");

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

}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // print our string
    ps.println(s);/*from   w  ww  .  j av a  2s. c o m*/

    // closing stream
    System.out.println("Closing Stream...");

    // close the stream
    ps.close();

}

From source file:Main.java

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

    PrintStream ps = new PrintStream(System.out);

    // append our character sequences
    ps.append(csq, 6, 11);/*from w  ww  .  j  a v  a2  s.c  om*/
    ps.append(csq, 0, 5);

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

}

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);//  w  w  w. j  av  a  2 s .  c  om

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

    // print our string
    ps.print(s);/*w  w  w. j ava 2 s.  com*/

    // flush the stream to see the results
    ps.flush();

    // print new string
    ps.println();
    ps.print("This is an example");

    // flush to see new string
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    long x = 1234567890l;
    try {/*from w w  w  . j av  a2s . com*/

        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) {
    long c = 1234567890L;
    try {//from   w ww.  j av a  2  s  .c o  m

        PrintStream ps = new PrintStream(System.out);

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

        // flush the stream
        ps.flush();

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

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(Locale.CANADA, "This is a %s application", s);

    // flush the stream
    ps.flush();/* w  w w  .ja  v  a 2s . c  om*/

}

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(Locale.UK, "This is a %s program", s);

    // flush to see the string
    ps.flush();//from   w w  w  .  j  a  v a  2 s  .  co  m

}