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) {
    float x = 1.23f;

    PrintStream ps = new PrintStream(System.out);

    // print float
    ps.print(x);

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

}

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

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

}

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);
    ps.print('b');

    // flush the stream
    ps.flush();//from   w ww  .  j  ava  2  s .  co m

}

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);
    ps.print(" This is an example");

    // flush the stream
    ps.flush();//from w ww.j  a  v a2 s.com

}

From source file:Main.java

public static void main(String[] args) {
    int x = 123;/*from  w w  w  .ja  va  2 s .  c o  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) {
    boolean bool = false;

    PrintStream ps = new PrintStream(System.out);

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

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    Object x = 50;/*  w  w w .  j a v  a 2s  . com*/
    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[]) throws Exception {
    ServerSocket ssock = new ServerSocket(1234);
    Socket sock = ssock.accept();
    ssock.close();/*w w  w .  j a va2  s.c  om*/

    PrintStream pstream = new PrintStream(sock.getOutputStream());
    pstream.print("count? ");
    BufferedReader input = new BufferedReader(new InputStreamReader(sock.getInputStream()));
    String line = input.readLine();
    pstream.println("");
    int count = Integer.parseInt(line);
    for (int i = count; i >= 0; i--) {
        pstream.println(i);
    }
    pstream.close();
    sock.close();
}

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);
    ps.print(c);/*www . jav  a 2 s  .  co m*/

    // flush the stream
    ps.flush();

}

From source file:Finger.java

public static void main(String[] arguments) throws Exception {
    StringTokenizer split = new StringTokenizer(arguments[0], "@");
    String user = split.nextToken();
    String host = split.nextToken();

    Socket digit = new Socket(host, 79);
    digit.setSoTimeout(20000);/*w  w w.ja  v a  2 s . co  m*/
    PrintStream out = new PrintStream(digit.getOutputStream());
    out.print(user + "\015\012");
    BufferedReader in = new BufferedReader(new InputStreamReader(digit.getInputStream()));
    boolean eof = false;
    while (!eof) {
        String line = in.readLine();
        if (line != null)
            System.out.println(line);
        else
            eof = true;
    }
    digit.close();
}