Java Code Examples for java.io.Writer#append()

The following examples show how to use java.io.Writer#append() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluckStacks.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void writeTo(Writer w) throws IOException {
  if (DEBUG) {
    w.append("stack.name='"+getThreadName()+"' runnable="+this.runnable + " lines=" + lines.size());
    w.append("\n");
  }
  boolean first = true;
  for (String line: lines) {
    w.append(line);
    w.append("\n");
    if (first) {
      first = false;
      if (breadcrumbs != null) {
        for (String bline: breadcrumbs) {
          w.append(bline).append("\n");
        }
      }
    }
  }
}
 
Example 2
Source File: DisplayMessage.java    From trader with Apache License 2.0 6 votes vote down vote up
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String encodedMessage = request.getParameter("message");
	String message = URLDecoder.decode(encodedMessage, "UTF-8");
	Writer writer = response.getWriter();
	writer.append("<!DOCTYPE html>");
	writer.append("<html>");
	writer.append("  <head>");
	writer.append("    <title>Stock Trader</title>");
	writer.append("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
	writer.append("  </head>");
	writer.append("  <body>");
	writer.append("    <img src=\"header.jpg\" width=\"534\" height=\"200\"/>");
	writer.append("    <p/>");
	writer.append("    "+message);
	writer.append("    <p/>");
	writer.append("    <form method=\"post\"/>");
	writer.append("      <input type=\"submit\" name=\"submit\" value=\"OK\" style=\"font-family: sans-serif; font-size: 16px;\" />");
	writer.append("    </form>");
	writer.append("    <br/>");
	writer.append("    <a href=\"https://github.com/IBMStockTrader\">");
	writer.append("      <img src=\"footer.jpg\"/>");
	writer.append("    </a>");
	writer.append("  </body>");
	writer.append("</html>");
}
 
Example 3
Source File: FilterDataPersistence.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public void persist(List<FileSupplier> fileSuppliers, Writer writer) throws IOException {
    Gson gson = new Gson();
    ImmutableList.Builder<Record> records = ImmutableList.builder();
    for (FileSupplier fileSupplier : fileSuppliers) {
        if (fileSupplier instanceof SplitFileSupplier) {
            records.add(new Record(
                    ((SplitFileSupplier) fileSupplier).getFilterData().getFilterType(),
                    ((SplitFileSupplier) fileSupplier).getFilterData().getIdentifier(),
                    fileSupplier.get().getName()));
        }
    }
    String recordsAsString = gson.toJson(records.build());
    try {
        writer.append(recordsAsString);
    } finally {
        writer.close();
    }
}
 
Example 4
Source File: Series.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void toXml(Writer result) throws IOException {
    if (seriesInstanceUID != null) {
        result.append("\n<");
        result.append(Xml.Level.SERIES.getTagName());
        result.append(" ");
        Xml.addXmlAttribute(Tag.SeriesInstanceUID, seriesInstanceUID, result);
        Xml.addXmlAttribute(Tag.SeriesDescription, seriesDescription, result);
        Xml.addXmlAttribute(Tag.SeriesNumber, seriesNumber, result);
        Xml.addXmlAttribute(Tag.Modality, modality, result);
        Xml.addXmlAttribute("DirectDownloadThumbnail", thumbnail, result);
        Xml.addXmlAttribute("WadoTransferSyntaxUID", wadoTransferSyntaxUID, result);
        Xml.addXmlAttribute("WadoCompressionRate",
            wadoCompression < 1 ? null : Integer.toString(wadoCompression), result);
        result.append(">");

        List<SopInstance> list = new ArrayList<>(sopInstanceMap.values());
        Collections.sort(list);
        for (SopInstance s : list) {
            s.toXml(result);
        }
        result.append("\n</");
        result.append(Xml.Level.SERIES.getTagName());
        result.append(">");
    }
}
 
Example 5
Source File: HTMLDialogProcessor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void generateTechIds(Writer w, String[] techIds) throws IOException {
    if (techIds.length == 0) {
        return;
    }
    w.append("addTechIds(");
    String sep = "";
    for (String id : techIds) {
        w.append(sep);
        w.append('"');
        w.append(id);
        w.append('"');
        sep = ", ";
    }
    w.append(").\n");
}
 
Example 6
Source File: EventsHelper.java    From ipst with Mozilla Public License 2.0 5 votes vote down vote up
public static void    addLine(Writer writer, String line) {
    try {
        writer.append(line);
        writer.append(StaticData.NEW_LINE);
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
Example 7
Source File: CustomJsonLayout.java    From summerframework with Apache License 2.0 5 votes vote down vote up
@Override
public void toSerializable(final LogEvent event, final Writer writer) throws IOException {
    if (complete && eventCount > 0) {
        writer.append(", ");
    }
    super.toSerializable(event, writer);
}
 
Example 8
Source File: RScriptExporter.java    From jfuzzylite with GNU General Public License v3.0 5 votes vote down vote up
/**
 Writes the header of the R script (e.g., import libraries)

 @param writer is the output where the header will be written to
 @param engine is the engine to export
 @throws IOException if any error occurs upon writing on the writer

 */
protected void writeScriptHeader(Writer writer, Engine engine) throws IOException {
    writer.append("#Code automatically generated with " + FuzzyLite.LIBRARY + ".\n\n");
    writer.append("library(ggplot2);\n");
    writer.append("\n");
    writer.append("engine.name = \"" + engine.getName() + "\"\n");
    if (!Op.isEmpty(engine.getDescription())) {
        writer.append(String.format(
                "engine.description = \"%s\"\n", engine.getDescription()));
    }
    writer.append("engine.fll = \"" + new FllExporter().toString(engine) + "\"\n\n");
}
 
Example 9
Source File: AcceptorGenerator.java    From artio with Apache License 2.0 5 votes vote down vote up
private void generateAcceptorClass(final Writer acceptorOutput) throws IOException
{
    acceptorOutput.append(fileHeader(packageName));
    acceptorOutput.append(
        "\n" +
        "public interface " + DICTIONARY_ACCEPTOR + "\n" +
        "{\n"
    );
}
 
Example 10
Source File: ModelToFile.java    From javascad with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Saves the models to the file.
 * @param context the color context to be used for the generation
 * @throws IOException if any IO error happens during opening, writing or closing the file
 */
public void saveToFile(IColorGenerationContext context) throws IOException {
	Writer writer = new FileWriter(file);
	try {
		for (IModel model : models) {
			writer.append(model.toScad(context).getScad());
		}
	}
	finally {
		writer.close();
	}
}
 
Example 11
Source File: TextNode.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
public void writeAll(Writer writer, IHTMLFilter htmlFilter, boolean convertIntoValidXML, boolean filterText)
		throws IOException {

	if (filterText) {
		return;
	}

	if (htmlFilter != null) {
		String newText = htmlFilter.modifyNodeText(tagName, getText());
		writer.append(newText);
	} else {
		writer.append(getText());
	}
}
 
Example 12
Source File: FileHandlerV1.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Appends metadata to a Writer. Does not flush the Writer.
 */
protected void appendGetMetadata(HttpServletRequest request, HttpServletResponse response, Writer responseWriter, IFileStore file) throws IOException,
		NoSuchAlgorithmException, JSONException, CoreException {
	JSONObject metadata = getMetadata(request, file);
	response.setHeader(ProtocolConstants.KEY_ETAG, metadata.getString(ProtocolConstants.KEY_ETAG));
	response.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
	OrionServlet.decorateResponse(request, metadata, JsonURIUnqualificationStrategy.ALL);
	responseWriter.append(metadata.toString());
}
 
Example 13
Source File: DiskBlobStoreTest.java    From anno4j with Apache License 2.0 5 votes vote down vote up
public void testAbandon() throws Exception {
	BlobVersion trx1 = store.newVersion("urn:test:trx1");
	Writer file = trx1.open("urn:test:file").openWriter();
	file.append("test1");
	trx1.commit();
	assertEquals(Arrays.asList(), Arrays.asList(store.getRecentModifications()));
	store.erase();
	assertEmpty(dir);
}
 
Example 14
Source File: Joda.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void printTo(Writer out, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException {
    if (hasMilliSecondPrecision) {
        out.write(String.valueOf(instant));
    } else {
        out.append(String.valueOf(instant / 1000));
    }
}
 
Example 15
Source File: FieldDirective.java    From sundrio with Apache License 2.0 5 votes vote down vote up
private void writeField(Writer writer, Property field, String block) throws IOException {
    if (field != null) {
        writer.append(field.toString());

        if (field.getAttribute(INIT) != null) {
            writer.append(" = ").append(getDefaultValue(field));
        }
    }
    writer.append(";");
}
 
Example 16
Source File: TestProcessor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public void writeTests(final ProcessorContext context, final Writer sb) throws IOException {
	sb.append("experiment ").append(toJavaString("Tests for " + context.currentPlugin)).append(" type: test {");
	for (final StringBuilder tests : serializedElements.values()) {
		sb.append(ln);
		sb.append(tests);
	}
	sb.append(ln).append('}');
	namesAlreadyUsed.clear();
}
 
Example 17
Source File: HttpMonitor.java    From sumk with Apache License 2.0 5 votes vote down vote up
private void outputActs(HttpServletRequest req, Writer writer) throws IOException {
	if (!"1".equals(req.getParameter("acts"))) {
		return;
	}
	writer.append(Arrays.toString(HttpActions.acts()));
	writer.append(TYPE_SPLIT);
}
 
Example 18
Source File: DefaultReleaseNotesData.java    From shipkit with MIT License 4 votes vote down vote up
@Override
public void toJson(Writer writable) throws IOException {
    writable.append(toJson());
}
 
Example 19
Source File: YamlBuilder.java    From groovy with Apache License 2.0 2 votes vote down vote up
/**
 * The YAML builder implements the <code>Writable</code> interface,
 * so that you can have the builder serialize itself the YAML payload to a writer.
 * <p>
 * Example:
 * <pre><code class="groovyTestCase">
 * def yaml = new groovy.yaml.YamlBuilder()
 * yaml { temperature 37 }
 *
 * def out = new StringWriter()
 * out {@code <<} yaml
 *
 * assert out.toString() == '''---
 * temperature: 37
 * '''
 * </code></pre>
 *
 * @param out a writer on which to serialize the YAML payload
 * @return the writer
 */
@Override
public Writer writeTo(Writer out) throws IOException {
    return out.append(toString());
}
 
Example 20
Source File: RScriptExporter.java    From jfuzzylite with GNU General Public License v3.0 1 votes vote down vote up
/**
 Writes an R script plotting multiple surfaces based on a data frame
 generated with the given number of values and scope for the two input
 variables on the output variables.

 @param engine is the engine to export
 @param writer is the output where the engine will be written to
 @param a is the first input variable
 @param b is the second input variable
 @param reader is an input stream of data whose lines contain
 space-separated input values
 @param outputVariables are the output variables to create the surface for
 @throws IOException if any error occurs upon writing on the writer

 */
public void writeScriptExportingDataFrame(Engine engine, Writer writer,
        InputVariable a, InputVariable b, Reader reader,
        List<OutputVariable> outputVariables) throws IOException {
    writeScriptHeader(writer, engine);

    writer.append("engine.fldFile = \"");
    new FldExporter().write(engine, writer, reader);
    writer.append("\"\n\n");

    writer.append("engine.df = read.delim(textConnection(engine.fld), header=TRUE, "
            + "sep=\" \", strip.white=TRUE)\n\n");

    writeScriptPlots(writer, a, b, outputVariables);
}