List of usage examples for java.io Writer append
public Writer append(char c) throws IOException
From source file:org.apache.commons.jci.examples.serverpages.JspGenerator.java
private void wrap(final StringBuilder pInput, final Writer pOutput) throws IOException { pOutput.append(" out.write(\""); pOutput.append(quote(pInput.toString())); pOutput.append("\");").append('\n'); }
From source file:com.bstek.dorado.view.ViewOutputter.java
@Override public void output(Object object, OutputContext context) throws Exception { Writer writer = context.getWriter(); writer.append("(function(){\n"); outputView((View) object, context); writer.append("return view;\n").append("})()"); }
From source file:org.inaetics.remote.EndpointDescriptorWriter.java
public void writeDocument(Writer writer, EndpointDescription... endpoints) throws IOException { writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); writer.append("<endpoint-descriptions xmlns=\"http://www.osgi.org/xmlns/rsa/v1.0.0\">\n"); for (EndpointDescription endpoint : endpoints) { appendEndpoint(writer, endpoint); }/* w ww. j a v a2 s. c o m*/ writer.append("</endpoint-descriptions>"); }
From source file:fi.okm.mpass.shibboleth.profile.impl.WriteMonitoringResult.java
/** * Writes the given message to the servlet response and returns a Spring webflow event. * @param httpResponse The servlet response. * @param message The message to be written to the servlet response. * @return The proceed event if the action was successful, IO_ERROR otherwise. *//*from w w w. j av a 2 s . c o m*/ protected Event writeAndReturn(final HttpServletResponse httpResponse, final String message) { try { final Writer out = new OutputStreamWriter(httpResponse.getOutputStream(), "UTF-8"); out.append(message); out.flush(); } catch (IOException e) { log.error("{}: Could not encode the JSON response", getLogPrefix(), e); httpResponse.setStatus(HttpStatus.SC_SERVICE_UNAVAILABLE); return ActionSupport.buildEvent(this, EventIds.IO_ERROR); } return ActionSupport.buildProceedEvent(this); }
From source file:org.structr.rest.servlet.CsvServlet.java
/** * Write list of objects to output//w w w . jav a 2s. c o m * * @param result * @param out * @param propertyView * @throws IOException */ public static void writeCsv(final Result result, final Writer out, final String propertyView) throws IOException { List<GraphObject> list = result.getResults(); boolean headerWritten = false; for (GraphObject obj : list) { // Write column headers if (!headerWritten) { StringBuilder row = new StringBuilder(); for (PropertyKey key : obj.getPropertyKeys(propertyView)) { row.append("\"").append(key.dbName()).append("\"").append(DELIMITER); } // remove last , int pos = row.lastIndexOf(DELIMITER); if (pos >= 0) { row.deleteCharAt(pos); } // append DOS-style line feed as defined in RFC 4180 out.append(row).append("\r\n"); // flush each line out.flush(); headerWritten = true; } StringBuilder row = new StringBuilder(); for (PropertyKey key : obj.getPropertyKeys(propertyView)) { Object value = obj.getProperty(key); row.append("\"").append((value != null ? escapeForCsv(value) : "")).append("\"").append(DELIMITER); } // remove last , row.deleteCharAt(row.lastIndexOf(DELIMITER)); out.append(row).append("\r\n"); // flush each line out.flush(); } }
From source file:com.joliciel.csvLearner.features.BestFeatureFinder.java
public void writeFirstLine(Writer writer, int numFeatures) { try {//from w w w.j av a 2s .com writer.append(CSVFormatter.format("outcome") + ","); writer.append(CSVFormatter.format("total entropy") + ","); for (int i = 1; i <= numFeatures; i++) { writer.append(CSVFormatter.format(i) + ","); writer.append("gain,"); } writer.append("\n"); writer.flush(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
From source file:org.sonar.plugins.csharp.fxcop.profiles.FxCopProfileExporter.java
private void printRule(Writer writer, FxCopRule fxCopRule) throws IOException { writer.append(" <Rule Enabled=\"True\" Name=\""); StringEscapeUtils.escapeXml(writer, fxCopRule.getName()); writer.append("\" SonarPriority=\""); StringEscapeUtils.escapeXml(writer, fxCopRule.getPriority()); writer.append("\"/>\n"); }
From source file:org.sonar.plugins.ideainspections.IdeaProfileExporter.java
private void appendRule(Writer writer, Rule rule, boolean enabled, boolean close) throws IOException { writer.append("<").append(INSPECTION_TOOL_NODE); appendAttribute(writer, INSPECTION_CLASS_ATTR, rule.getConfigKey()); appendAttribute(writer, INSPECTION_LEVEL_ATTR, IdeaUtils.toSeverity(rule.getPriority())); appendAttribute(writer, INSPECTION_ENABLED, Boolean.toString(enabled)); if (close)//w w w.jav a 2 s . co m writer.append("/>\n"); }
From source file:org.sonar.api.profiles.XMLProfileSerializer.java
private void appendAlerts(RulesProfile profile, Writer writer) throws IOException { if (!profile.getAlerts().isEmpty()) { writer.append("<alerts>"); for (Alert alert : profile.getAlerts()) { appendAlert(alert, writer);//from w w w . jav a2 s. c om } writer.append("</alerts>"); } }
From source file:org.sonar.plugins.gosu.codenarc.CodeNarcProfileExporterTest.java
@Test public void shouldFailToExport() throws IOException { Writer writer = Mockito.mock(Writer.class); Mockito.when(writer.append(Matchers.any(CharSequence.class))).thenThrow(new IOException()); exporter = new CodeNarcProfileExporter(writer); try {/*from w w w. ja v a 2s . co m*/ exporter.exportProfile(profile); Fail.fail("Should have failed"); } catch (IllegalStateException e) { assertThat(e.getMessage()).contains("Fail to export CodeNarc profile"); } }