Example usage for java.io Writer append

List of usage examples for java.io Writer append

Introduction

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

Prototype

public Writer append(char c) throws IOException 

Source Link

Document

Appends the specified character to this writer.

Usage

From source file:com.dm.material.dashboard.candybar.helpers.ReportBugsHelper.java

@Nullable
private static String buildActivityList(Context context, File folder) {
    try {/*  w ww  .j av a2 s  . c o m*/
        File fileDir = new File(folder.toString() + "/" + "activity_list.xml");
        Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileDir), "UTF8"));

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> appList = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.GET_RESOLVED_FILTER);

        try {
            Collections.sort(appList, new ResolveInfo.DisplayNameComparator(context.getPackageManager()));
        } catch (Exception ignored) {
        }

        boolean first = true;
        for (ResolveInfo app : appList) {

            if (first) {
                first = false;
                out.append("<!-- ACTIVITY LIST -->");
                out.append("\n\n\n");
            }

            String name = app.activityInfo.loadLabel(context.getPackageManager()).toString();
            String activity = app.activityInfo.packageName + "/" + app.activityInfo.name;
            out.append("<!-- ").append(name).append(" -->");
            out.append("\n").append(activity);
            out.append("\n\n");
        }
        out.flush();
        out.close();

        return fileDir.toString();
    } catch (Exception | OutOfMemoryError e) {
        Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
    }
    return null;
}

From source file:dataGen.DataGen.java

/**
 * Creates normal or uniform distributed Test-Data, without correlation.
 * The resulting Data is stored in the resources Folder.
 * @param dimensions/*w w w  .j a  va  2  s . c  o m*/
 *       The dimension count of the resulting Data
 * @param rowCount
 *       How many data tuples should be created?
 * @throws IOException
 *       If Stream to a File couldn't be written/closed 
 */
public static void genData(int dimensions, int rowCount) throws IOException {
    logger.info("Generating uniform random Data with " + rowCount + " Tuples in " + dimensions + " dimensions");
    Writer fw = new FileWriter("src/main/resources/random-" + rowCount + "-" + dimensions + ".dat");
    Random gen = new Random();

    for (int i = 1; i <= rowCount; i++) {
        // Each Row should start with the Row count
        String row = i + " ";
        // Files should be created OS/Language independent
        DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance();
        dfs.setDecimalSeparator('.');
        NumberFormat nf = new DecimalFormat("0.000000000", dfs);

        for (int j = 0; j < dimensions; j++) {
            Float n = gen.nextFloat();
            row = row + nf.format(n) + " ";
        }
        fw.write(row);
        fw.append(System.getProperty("line.separator"));
    }
    fw.close();
    logger.info(rowCount + " entries generated");
}

From source file:org.cbarrett.common.spring.view.XStreamMarshallerWithPI.java

/**
 * {@inheritDoc}//from w  w w .  j  a  v  a  2 s  . c o  m
 */
@Override
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
    writer.append(BOMUtility.getBOM(DEFAULT_ENCODING));
    writer.append("<?xml version=\"1.0\" encoding=\"" + DEFAULT_ENCODING + "\"?>\n");
    super.marshalWriter(graph, writer);
}

From source file:com.katsu.json.serializer.StringSerializer.java

public void parse(Object obj, Properties properties, Writer writer) throws IOException {
    writer.append(Constants.DOUBLE_MARK);
    if (properties != null
            && properties.getProperty(JsonProperty.HTML_ESCAPE.getValue()).equals(Constants.TRUE))
        writer.append(escapeCharacter((String) obj));
    else//ww  w  . j  a  va 2 s.  c om
        writer.append((String) obj);
    writer.append(Constants.DOUBLE_MARK);
}

From source file:otsopack.commons.network.communication.representations.SemanticFormatRepresentation.java

@Override
public void write(Writer writer) throws IOException {
    writer.append(this.data);
}

From source file:org.tautua.boson.json.core.adapters.MapAdapter.java

public void _write(Map<String, E> map, Writer writer) throws IOException {
    writer.append("{");
    Iterator<Map.Entry<String, E>> itr = map.entrySet().iterator();
    while (itr.hasNext()) {
        Map.Entry<String, E> entry = itr.next();
        E e = entry.getValue();// w  w  w .j a  v  a  2 s .c o  m
        //TODO: escaping, null TypeAdapter
        writer.append("\"").append(entry.getKey()).append("\":");
        if (itr.hasNext()) {
            writer.append(",");
        }
    }
    writer.append("}");
}

From source file:com.bstek.dorado.view.resolver.ClientSettingsOutputter.java

protected void writeSetting(Writer writer, String key, Object value, boolean quote) throws IOException {
    writer.append(",\n\"").append(key).append('"').append(':');
    if (quote) {//from   w w w  . j a  v a 2  s.  c om
        writer.append('"');
    }
    writer.append(StringEscapeUtils.escapeJavaScript(String.valueOf(value)));
    if (quote) {
        writer.append('"');
    }
}

From source file:org.tautua.boson.json.core.LiteralAdapter.java

public void write(T t, Writer writer) throws IOException {
    if (t == null) {
        writer.append("null");
    } else {// w  w  w  .  j  a v  a  2  s.  c o  m
        _write(t, writer);
    }
}

From source file:org.cloud.mblog.utils.DateFormatTag.java

@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
        throws TemplateException, IOException {
    String text = "";
    // text//from   w  w w  . j av  a 2 s .co m
    if (params.get("date") != null) {
        text = ((SimpleScalar) params.get("date")).getAsString();
    }
    Writer out = env.getOut();

    out.append(getOffsetTime(text));
    if (body != null) {
        body.render(env.getOut());
    }
}

From source file:com.github.jknack.handlebars.internal.Text.java

@Override
protected void merge(final Context scope, final Writer writer) throws IOException {
    writer.append(text);
}