Example usage for java.io BufferedWriter write

List of usage examples for java.io BufferedWriter write

Introduction

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

Prototype

public void write(int c) throws IOException 

Source Link

Document

Writes a single character.

Usage

From source file:Main.java

public static void writeAttribute(String name, long value, BufferedWriter w) throws IOException {
    w.write(name + "=\"" + value + "\"");
}

From source file:Main.java

public static void writeAttribute(String name, double value, BufferedWriter w) throws IOException {
    w.write(name + "=\"" + value + "\"");
}

From source file:Main.java

public static void writeAttribute(String name, boolean value, BufferedWriter w) throws IOException {
    w.write(name + "=\"" + value + "\"");
}

From source file:Main.java

public static void writeNode(BufferedWriter bw, String node) throws IOException {
    bw.write("\t" + node.replace("\n", "\n\t"));
    bw.newLine();//from  w w  w  .  j av  a  2  s  .  c o  m
    bw.newLine();
}

From source file:Main.java

public static void writeFile(File file, String data) throws IOException {
    FileWriter fstream = new FileWriter(file);
    BufferedWriter out = new BufferedWriter(fstream);
    out.write(data);
    out.close();//from  www  . j a v  a2 s. c o m
}

From source file:Main.java

public static String getURLContent(String urlStr) throws Exception {
    URL url = new URL(urlStr);
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);/*from  ww w  .  j a  va2  s. c  o  m*/
    connection.connect();
    OutputStream ous = connection.getOutputStream();
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(ous));
    bw.write("index.htm");
    bw.flush();
    bw.close();

    printRequestHeaders(connection);
    InputStream ins = connection.getInputStream();

    BufferedReader br = new BufferedReader(new InputStreamReader(ins));
    StringBuffer sb = new StringBuffer();
    String msg = null;
    while ((msg = br.readLine()) != null) {
        sb.append(msg);
        sb.append("\n"); // Append a new line
    }
    br.close();
    return sb.toString();
}

From source file:Main.java

/**
 * /*from   w w  w.j  a  v  a 2  s.  c  o m*/
 * @param os
 * @param request
 * @param charsetName
 * @throws IOException
 */
public static final void writeString(OutputStream os, String request, String charsetName) throws IOException {
    OutputStreamWriter writer = new OutputStreamWriter(os, charsetName);
    BufferedWriter bw = new BufferedWriter(writer);
    bw.write(request);
    bw.write("\r\n");
    bw.flush();
}

From source file:Main.java

private static void _writeNode(BufferedWriter writer, String nodeName, String nodeValue) throws Exception {
    writer.write("<" + nodeName + ">");
    writer.write(nodeValue);//from w  w w .  j a  v  a  2  s  .  c om
    writer.write("</" + nodeName + ">");
    writer.newLine();
}

From source file:Main.java

public static void indent(int num, BufferedWriter w) throws IOException {
    for (int i = 0; i < num; i++)
        w.write("\t");
}

From source file:Main.java

public static void writeTextFile(File file, String text) {
    try {/*  w w w . j  av  a2 s .com*/
        BufferedWriter bw = new BufferedWriter(new FileWriter(file));
        bw.write(text);
        bw.flush();
        bw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}