Example usage for java.io PrintStream print

List of usage examples for java.io PrintStream print

Introduction

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

Prototype

public void print(Object obj) 

Source Link

Document

Prints an object.

Usage

From source file:Main.java

public static void main(String[] args) {
    long x = 1234567890l;
    try {/* w w w.  ja v a 2  s  . 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) {

    PrintStream ps = new PrintStream(System.out);

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

    // print new line
    ps.println();//w w w . j a v a2s . com

    // 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) {
    String s = "from java2s.com.";

    PrintStream ps = new PrintStream(System.out);

    // print our string
    ps.print(s);

    // flush the stream to see the results
    ps.flush();//from   w w w.j  a  v  a 2s.  c om

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

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

}

From source file:AnotherBeerServer.java

public static void main(String args[]) throws Exception {
    ServerSocket ssock = new ServerSocket(1234);
    System.out.println("Listening");
    Socket sock = ssock.accept();
    ssock.close(); // no more connects

    PrintStream ps = new PrintStream(sock.getOutputStream());

    // ask for count
    ps.print("count? ");
    BufferedReader input = new BufferedReader(new InputStreamReader(sock.getInputStream()));

    // read and parse it
    String line = input.readLine();
    ps.println("");
    int count = Integer.parseInt(line);
    for (int i = count; i >= 0; i--) {
        ps.println(i + " Java Source and Support.");
    }//from w w  w.j  ava 2  s . c  o  m
    ps.close();
    sock.close();
}

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   ww  w.j a va  2s . c o  m
    ps.print("from java2s.com");

    // 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.  c o  m*/
    ps.print("from java2s.com");

    // 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  v  a  2 s. com*/
    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  www .j  a v a  2  s  . co  m*/
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    Object c = 15;// w w w  .  j a  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) {

    PrintStream ps = new PrintStream(System.out);

    // print a boolean and change line
    ps.println(true);//from   w w  w .  ja v  a 2  s  .co  m
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();

}