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:com.googlecode.jsonplugin.JSONUtil.java

/**
 * Serializes an object into JSON to the given writer, excluding any properties matching
 * any of the regular expressions in the given collection.
 *
 * @param writer            Writer to serialize the object to
 * @param object            object to be serialized
 * @param excludeProperties Patterns matching properties to ignore
 * @throws IOException/* w w  w  . j  a  va2 s  .co m*/
 * @throws JSONException
 */
public static void serialize(Writer writer, Object object, Collection<Pattern> excludeProperties,
        Collection<Pattern> includeProperties, boolean excludeNullProperties)
        throws IOException, JSONException {
    writer.write(serialize(object, excludeProperties, includeProperties, true, excludeNullProperties));
}

From source file:com.wavemaker.json.JSONMarshaller.java

private static void writeIndents(Writer writer, int level) throws IOException {

    for (int i = 0; i < level; i++) {
        writer.write('\t');
    }// w w  w  . j  a  v a 2  s.c  o  m
}

From source file:net.sf.jabref.exporter.FileActions.java

/**
 * Writes the file encoding information.
 *
 * @param encoding String the name of the encoding, which is part of the file header.
 *///from w w  w . j a va  2  s .c o  m
private static void writeBibFileHeader(Writer out, Charset encoding) throws IOException {
    out.write("% ");
    out.write(Globals.encPrefix + encoding);
}

From source file:com.amalto.core.storage.record.DataRecordXmlWriter.java

protected static void writeMetadataField(Writer writer, MetadataField metadataField, Object value)
        throws IOException {
    String fieldName = metadataField.getFieldName();
    if (value != null) { // TMDM-7521: Don't serialize null values to XML (prevent "null" string in result).
        writer.write("<" + fieldName + ">" + String.valueOf(value) + "</" + fieldName + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }//from w  w  w  .  j  ava2s.co m
}

From source file:com.github.jsonj.tools.JsonSerializer.java

/**
 * Writes the object out as json.// www. j a  v a  2  s. com
 * 
 * @param out
 *            output writer
 * @param json
 *            a {@link JsonElement}
 * @param pretty
 *            if true, a properly indented version of the json is written
 * @throws IOException
 *             if there is a problem writing to the writer
 */
public static void serialize(final Writer out, final JsonElement json, final boolean pretty)
        throws IOException {
    BufferedWriter bw = new BufferedWriter(out);
    serialize(bw, json, pretty, 0);
    if (pretty) {
        out.write('\n');
    }
    bw.flush();
}

From source file:com.iksgmbh.sql.pojomemodb.utils.FileUtil.java

public static void createNewFileWithContent(IOEncodingHelper encodingHelper, final File file,
        final String content) throws Exception {

    if (encodingHelper == null) {
        encodingHelper = IOEncodingHelper.STANDARD;
    }//from   w  w  w  . j  a va2  s  .c om

    if (file == null) {
        throw new IllegalArgumentException("FileUtil: file must not be null");
    }

    createNewFile(file);

    Writer writer = null;
    try {
        writer = encodingHelper.getOutputStreamWriter(file);
        writer.write(content);
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
}

From source file:dataGen.DataGen.java

/**
 * Save the Date with the FileWriter//ww w .  ja v  a  2 s  .  co m
 * @param values
 * @param fw
 * @param nf
 * @throws IOException
 */
public static void saveData(TupleList values, Writer fw, NumberFormat nf) throws IOException {
    for (int i = 0; i < values.size(); i++) {
        String row = i + 1 + " ";
        //String row = "";

        for (int j = 0; j < values.get(i).size(); j++) {
            row = row + nf.format(values.get(i).getValue(j)) + " ";
        }
        fw.write(row);
        fw.append(System.getProperty("line.separator"));
    }
    fw.close();
}

From source file:com.portfolio.data.utils.DomUtils.java

public static void saveString(String str, String fileName) throws Exception {
    //  ---------------------------------------------------
    Writer fwriter = new OutputStreamWriter(new FileOutputStream(fileName), "UTF-8");
    fwriter.write(str);
    fwriter.close();/*from  ww w .  ja va 2s  . co  m*/
}

From source file:com.iksgmbh.sql.pojomemodb.utils.FileUtil.java

public static void appendToFile(final File file, final String text) throws IOException {
    final String oldFileContent;
    final String newFileContent;

    if (file.exists()) {
        oldFileContent = getFileContent(file);
    } else {// ww w  .ja  v  a  2  s . c o m
        oldFileContent = "";
    }

    if (oldFileContent.length() > 0) {
        newFileContent = oldFileContent + getSystemLineSeparator() + text;
    } else {
        newFileContent = text;
    }

    Writer writer = null;
    try {
        writer = IOEncodingHelper.STANDARD.getBufferedWriter(file);
        writer.write(newFileContent);
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
}

From source file:net.sf.jabref.exporter.FileActions.java

private static void writePreamble(Writer fw, String preamble) throws IOException {
    if (preamble != null) {
        fw.write("@PREAMBLE{");
        fw.write(preamble);//  ww  w. j a  v a  2 s . co m
        fw.write('}' + Globals.NEWLINE + Globals.NEWLINE);
    }
}