Example usage for java.io PrintStream write

List of usage examples for java.io PrintStream write

Introduction

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

Prototype

private void write(String s) 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {
    byte c = 70;/* w  w w  . jav a 2 s  .  com*/

    PrintStream ps = new PrintStream(System.out);

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    byte c = 70;/*from   w w  w . j a  v  a  2 s.c om*/
    PrintStream ps = new PrintStream("c:/text.txt");

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) {
    byte c = 70;/*  w w w .j  a  va 2  s . c  om*/

    PrintStream ps = new PrintStream(System.out, true);

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    byte c = 70;/*www .  j a  v  a  2s  .  c o m*/
    PrintStream ps = new PrintStream("c:/text.txt", "UTF8");

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    byte c = 70;/*from   w  w w  .  ja  v a 2 s . c om*/
    PrintStream ps = new PrintStream(new File("c:/text.txt"));

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) throws UnsupportedEncodingException {
    byte c = 70;/*from  w ww.j av a 2s .c  o  m*/

    PrintStream ps = new PrintStream(System.out, true, "UTF8");

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    byte c = 70;// w ww  .  j a va 2s .co m
    PrintStream ps = new PrintStream(new File("c:/text.txt"), "ASCII");

    // write byte c which is character F in ASCII
    ps.write(c);

    // flush the stream
    ps.flush();
    ps.close();
}

From source file:com.zimbra.cs.imap.ImapMessage.java

public static void main(String[] args) {
    PrintStream ps = new PrintStream(System.out);
    ps.print(ImapHandler.LINE_SEPARATOR_BYTES);
    String[] samples = new String[] { null, "test", "\u0442", "ha\nnd", "\"dog\"", "ca\"t", "\0fr\0og\0" };
    for (String s : samples) {
        nstring2047(ps, s);/*w  w w  . ja v  a  2 s. c om*/
        ps.write(' ');
        nstring(ps, s);
        ps.write(' ');
        astring(ps, s);
        ps.write(' ');
        aSTRING(ps, s);
        ps.write('\n');
    }
}

From source file:Redirect.java

public static void main(String args[]) throws Exception {
    PrintStream origOut = System.out;
    PrintStream origErr = System.err;

    InputStream stdin = null;//from   w ww . j a  v  a 2  s  . c o  m
    stdin = new FileInputStream("Redirect.in");
    PrintStream stdout = null;
    stdout = new PrintStream(new FileOutputStream("Redirect.out"));
    PrintStream stderr = null;
    stderr = new PrintStream(new FileOutputStream("Redirect.err"));
    origOut.println("1");
    System.out.println("2");
    origOut.println("3");
    System.err.println("4");
    origErr.println("5");

    System.setIn(stdin);
    System.setOut(stdout);
    System.setErr(stderr);

    origOut.println("\nR");
    System.out.println("T");
    origOut.println("Tq");
    System.err.println("Tqw");
    origErr.println("Test");

    origOut.println("\nRedirect:  Round #3");
    int inChar = 0;
    while (-1 != inChar) {
        try {
            inChar = System.in.read();
        } catch (Exception e) {
            // Clean up the output and bail.
            origOut.print("\n");
            break;
        }
        origOut.write(inChar);
    }

    stdin.close();
    stdout.close();
    stderr.close();

    System.exit(0);
}

From source file:org.wso2.andes.tools.security.Passwd.java

private static void output(String user, byte[] encoded) throws IOException {

    //        File passwdFile = new File("qpid.passwd");

    PrintStream ps = new PrintStream(System.out);

    user += ":";//from  www.  java 2  s .  co  m
    ps.write(user.getBytes("utf-8"));

    for (byte b : encoded) {
        ps.write(b);
    }

    ps.println();

    ps.flush();
    ps.close();
}