Example usage for java.io Writer write

List of usage examples for java.io Writer write

Introduction

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

Prototype

public void write(String str) throws IOException 

Source Link

Document

Writes a string.

Usage

From source file:Main.java

static protected void writeCloseElement(Writer out, boolean newLine) throws IOException {
    out.write('>');
    if (newLine) {
        out.write('\n');
    }//from  w  ww.j  ava  2s .c  o m
}

From source file:Main.java

static protected void writeEndElement(Writer out, String elementName) throws IOException {
    out.write("</");
    out.write(elementName);/*from   w ww  .  j  a v  a  2  s .  c  o m*/
    out.write(">\n");
}

From source file:Main.java

static protected void writeStartElement(Writer out, String elementName) throws IOException {
    out.write("<");
    out.write(elementName);/*from  w w w. j  ava 2  s.  c om*/
    out.write(" ");
}

From source file:Main.java

/**
 * Start XML element and close it. Ex : <elementName>
 * /*from   ww w .j av  a2s . co  m*/
 * @param elementName
 * @param endTag
 * @param writer
 * @throws IOException
 */
public static void startElement(String elementName, boolean endTag, Writer writer) throws IOException {
    writer.write("<");
    writer.write(elementName);
    if (endTag) {
        writer.write(">");
    }
}

From source file:Main.java

public static void writeStr(OutputStream out, String str, String charset) throws IOException {
    if (TextUtils.isEmpty(charset))
        charset = "UTF-8";

    Writer writer = new OutputStreamWriter(out, charset);
    writer.write(str);
    writer.flush();/*from   w  w w.  ja  v  a2 s .co m*/
}

From source file:Main.java

private static void print(Writer writer, char c) {
    try {//from ww  w . j av a  2  s  . c  o m
        writer.write(c);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:Main.java

private static void print(Writer writer, String s) {
    try {/*  ww  w . jav a  2 s.c  o m*/
        writer.write(s);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:Main.java

static protected void writeAttribute(Writer out, String attributeName, String value) throws IOException {
    out.write(attributeName);
    out.write("=\"");
    out.write(value);//from   ww w . j av  a2  s.  co  m
    out.write("\" ");
}

From source file:com.cybernostics.jsp2thymeleaf.api.expressions.function.SymbolWriter.java

public static void write(Writer w, String s) {
    try {/* w  w  w  .ja va2 s  . c  om*/
        w.write(symbolMap.getOrDefault(s, s));
    } catch (IOException ex) {
        Logger.getLogger(SymbolWriter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Main.java

/**
 * Comprime uma string utilizando o GZIP
 * /*from ww w. j a v  a  2s .c o m*/
 * @param str
 * @param encoding
 * @return
 */
public static String gzipCompressString(String str, String encoding) {
    try {
        if (str == null || str.length() == 0) {
            return null;
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(out);
        Writer writer = new OutputStreamWriter(gzip, encoding);
        writer.write(str);
        writer.close();
        byte[] compressedBytes = out.toByteArray();
        return new String(Base64.encodeBase64(compressedBytes), encoding);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}