Example usage for java.io Writer flush

List of usage examples for java.io Writer flush

Introduction

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

Prototype

public abstract void flush() throws IOException;

Source Link

Document

Flushes the stream.

Usage

From source file:Streams.java

public static void drain(InputStream is, Writer w) throws IOException {
    Reader r = new InputStreamReader(is);
    drain(r, w);//w  w w  .  j  ava  2s.co  m
    w.flush();
}

From source file:Main.java

public static void writeToWriter(Enumeration enumList, Writer out) throws IOException {
    while (enumList.hasMoreElements()) {
        out.write(enumList.nextElement().toString());
        out.write(newLine);/* w  ww  . j ava 2s .co  m*/
    }
    out.flush();
}

From source file:DocWriter.java

public static void writeNodeToStream(Node node, Writer out) throws IOException {
    serializeNode(node, out, "");
    out.write('\n');
    out.flush();
}

From source file:DocWriter.java

/**
 * Writes a document to a stream//from  w w w  .j a  va 2  s.  c o  m
 * 
 * @param doc
 *        the XML docuument to write
 * @param out
 *        the output stream to write to
 * @throws IOException
 */
public static void writeDocToStream(Document doc, Writer out) throws IOException {
    serializeNode(doc, out, "");
    out.write('\n');
    out.flush();
}

From source file:com.google.caja.ancillary.servlet.UploadPage.java

private static void writeHeader(HttpServletResponse resp) throws IOException {
    resp.setStatus(200);/*w  ww . j  a v  a  2 s .  c  o m*/
    resp.setContentType("text/html;charset=UTF-8");
    Writer out = resp.getWriter();
    out.write("<h1>Loading&hellip;</h1>");
    out.flush();
}

From source file:Main.java

public static void transfer(Reader reader, Writer writer) throws IOException {

    char[] buf = new char[8192];
    int count = 0;

    while ((count = reader.read(buf)) >= 0) {

        writer.write(buf, 0, count);//from   ww w. j  a v  a 2 s  .co m
    }
    writer.flush();
}

From source file:Main.java

/**
 * Dump a <code>String</code> to a text file.
 *
 * @param file The output file//from   w  w  w. j  a  v a 2s .  c  o m
 * @param string The string to be dumped
 * @param encoding The encoding for the output file or null for default platform encoding
 * @exception IOException IO Error
        
 */
public static void serializeString(File file, String string, String encoding) throws IOException {
    final Writer fw = (encoding == null) ? new FileWriter(file)
            : new OutputStreamWriter(new FileOutputStream(file), encoding);
    try {
        fw.write(string);
        fw.flush();
    } finally {
        fw.close();
    }
}

From source file:co.cask.cdap.filetailer.tailer.TailerLogUtils.java

public static void writeLineToFile(String filePath, String line) throws IOException {
    Writer writer = new FileWriter(filePath, true);
    writer.write(line + "\n");
    writer.flush();
    writer.close();/*  w  w  w . j  ava 2 s . co m*/
}

From source file:boxConnection.SerBoxTelnet.java

private static void createTelnetSession(String command) throws IOException, InterruptedException {
    telnet.connect(ControlMain.getActiveBox().getDboxIp());
    OutputStream ostream = telnet.getOutputStream();
    Writer writer = new OutputStreamWriter(ostream);
    writer.write(ControlMain.getActiveBox().getLogin() + "\n");
    writer.flush();
    Thread.sleep(1000);//from   ww w  . j  ava2s.co m
    writer.write(ControlMain.getActiveBox().getPassword() + "\n");
    writer.flush();
    Thread.sleep(1000);
    writer.write(command + "\n");
    writer.flush();
    closeTelnetSession();
}

From source file:com.hunantv.fw.utils.StreamUtils.java

/**
 * Copy the contents of the given String to the given output OutputStream.
 * Leaves the stream open when done.//from ww w .j  a v a2  s  . c  o  m
 * @param in the String to copy from
 * @param charset the Charset
 * @param out the OutputStream to copy to
 * @throws IOException in case of I/O errors
 */
public static void copy(String in, Charset charset, OutputStream out) throws IOException {
    Writer writer = new OutputStreamWriter(out, charset);
    writer.write(in);
    writer.flush();
}