Example usage for java.io BufferedWriter BufferedWriter

List of usage examples for java.io BufferedWriter BufferedWriter

Introduction

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

Prototype

public BufferedWriter(Writer out) 

Source Link

Document

Creates a buffered character-output stream that uses a default-sized output buffer.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BufferedWriter out = new BufferedWriter(new FileWriter("filename", true));
    out.write("aString");
    out.close();//from   ww  w. j a v  a  2  s  . co  m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedWriter bufferedWriter = null;
    bufferedWriter = new BufferedWriter(new FileWriter("yourFile.txt"));
    bufferedWriter.write("string");
    bufferedWriter.newLine();//w w  w  . ja va 2  s .  com
    bufferedWriter.write("string");
}

From source file:Main.java

License:asdf

public static void main(String[] argv) throws Exception {

    Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("outfilename"), "8859_1"));
    out.write("asdf");
    out.close();//from  w  ww .j  a  v  a  2s  . co  m
}

From source file:Main.java

License:asdf

public static void main(String[] argv) throws Exception {

    Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("outfilename"), "UTF8"));
    out.write("asdf");
    out.close();//from ww w.j a v a  2s . co  m
}

From source file:Main.java

public static void main(String[] args) {
    String destFile = "test.txt";

    try (BufferedWriter bw = new BufferedWriter(new FileWriter(destFile))) {
        bw.append("test");
        bw.newLine();/*  ww w.  j  a v  a 2 s  . com*/
        bw.append("test1");
        bw.newLine();
        bw.append("test2");
        bw.newLine();
        bw.append("test3");

        bw.flush();
    } catch (Exception e2) {
        e2.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    InputStream in = System.in;
    BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));

    int letter;//from w ww .  ja v  a  2s. co  m

    while ((letter = in.read()) != -1) {
        bw.write((char) letter);
        bw.flush();
    }
}

From source file:BufferedWriterDemo.java

public static void main(String args[]) throws Exception {

    FileWriter fw = new FileWriter(args[0]);

    BufferedWriter bw = new BufferedWriter(fw);

    // Write strings to the file
    for (int i = 0; i < 12; i++) {
        bw.write("Line " + i + "\n");
    }/*from w ww . j a v a  2s .  co m*/

    // Close buffered writer
    bw.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileWriter file = new FileWriter("a.html");
    BufferedWriter buffer = new BufferedWriter(file);
    PrintWriter out = new PrintWriter(buffer);
    out.println("<html>\n\t<body>");
    out.println("\t</body>\n</html>");
    out.close();// w  w w.j a v a 2s . c om
    buffer.close();
    file.close();
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {

    FileWriter fw = new FileWriter(args[0]);
    BufferedWriter bw = new BufferedWriter(fw);
    PrintWriter pw = new PrintWriter(bw, false);

    pw.println(true);//from   www.ja va 2s  .c  o  m
    pw.println('A');
    pw.println(500);
    pw.println(40000L);
    pw.println(45.67f);
    pw.println(45.67);
    pw.println("Hello");
    pw.println(new Integer("99"));

    pw.close();
}

From source file:MainClass.java

public static void main(String args[]) {
    try {//from ww w .j a  va  2s.  co  m
        FileWriter fw = new FileWriter(args[0]);

        BufferedWriter bw = new BufferedWriter(fw);

        for (int i = 0; i < 12; i++) {
            bw.write("Line " + i + "\n");
        }

        bw.close();
    } catch (Exception e) {
        System.out.println("Exception: " + e);
    }
}