Example usage for java.io PrintStream println

List of usage examples for java.io PrintStream println

Introduction

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

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminate the line.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    try {//from   w ww .  j  av a2  s .  c  o  m
        File tempFile = File.createTempFile("myfile", ".tmp");
        FileOutputStream fout = new FileOutputStream(tempFile);
        PrintStream out = new PrintStream(fout);
        out.println("some text");
    } catch (IOException ex) {
        System.out.println("There was a problem creating/writing to the temp file");
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Socket t = new Socket("127.0.0.1", 7);
    DataInputStream dis = new DataInputStream(t.getInputStream());
    PrintStream ps = new PrintStream(t.getOutputStream());
    ps.println("Hello");
    String str = dis.readUTF();//  w  w w . j a va  2s. c o m
    if (str.equals("Hello"))
        System.out.println("Alive!");
    else
        System.out.println("Dead");
    t.close();
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    ServerSocket ss = ssf.createServerSocket(5432);
    while (true) {
        Socket s = ss.accept();//from  w w  w .  j  av  a  2 s  .co  m
        PrintStream out = new PrintStream(s.getOutputStream());
        out.println("Hi");
        out.close();
        s.close();
    }

}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    System.setProperty("javax.net.ssl.keyStore", "mykeystore");
    System.setProperty("javax.net.ssl.keyStorePassword", "wshr.ut");
    SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    ServerSocket ss = ssf.createServerSocket(5432);
    while (true) {
        Socket s = ss.accept();// w  ww  . j av a 2 s .c  o m
        PrintStream out = new PrintStream(s.getOutputStream());
        out.println("Hi");
        out.close();
        s.close();
    }

}

From source file:Main.java

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

    // create a new PrintStream
    PrintStream ps = new PrintStream(System.out);

    // print a string
    ps.println(s);

    // check for errors and print
    ps.print(ps.checkError());//from w w w.  j a v a2  s. c o m
    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);

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

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

}

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);
    ps.print("from java2s.com");

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

}

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);
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();/*www .  j a v a 2s .c o m*/

}

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);
    ps.print("from java2s.com");

    // flush the stream
    ps.flush();/* w w w  . java  2s. c  o  m*/

}

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);
    ps.print("from java2s.com");

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

}