List of usage examples for java.io Writer flush
public abstract void flush() throws IOException;
From source file:com.googlecode.jsfFlex.phaseListener.NameValueServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { Map<? extends Object, ? extends Object> objectMap = null; try {//w w w. j a v a 2 s .co m objectMap = (Map<? extends Object, ? extends Object>) invokeResourceMethod(context, componentId, methodToInvoke, null, null); } catch (Exception methodInvocationException) { throw new ServletException(methodInvocationException); } HttpServletResponse response = HttpServletResponse.class.cast(context.getExternalContext().getResponse()); response.setContentType(PLAIN_CONTENT_TYPE); if (objectMap != null) { StringBuilder responseContent = new StringBuilder(); for (Iterator<? extends Object> iterate = objectMap.keySet().iterator(); iterate.hasNext();) { Object currKey = iterate.next(); Object currValue = objectMap.get(currKey); String statementToWrite = currKey.toString() + EQUAL_CHAR + currValue.toString() + SEPARATOR_CHAR; responseContent.append(statementToWrite); } _log.info("Flushing content : " + responseContent.toString()); Writer writer = response.getWriter(); writer.write(responseContent.toString()); writer.flush(); } }
From source file:com.googlecode.jsfFlex.phaseListener.ArrayServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { JSONArray methodResult = null;// www. j av a 2s.c o m try { methodResult = JSONArray.class .cast(invokeResourceMethod(context, componentId, methodToInvoke, null, null)); } catch (Exception methodInvocationException) { throw new ServletException(methodInvocationException); } HttpServletResponse response = HttpServletResponse.class.cast(context.getExternalContext().getResponse()); response.setContentType(XML_CONTENT_TYPE); StringBuilder responseContent = new StringBuilder(); responseContent.append(XML_HEAD); responseContent.append(XML_RESULT_ROOT_START_TAG); try { responseContent.append(JSONConverter.convertJSONArrayToXMLString(methodResult)); } catch (JSONException jsonException) { throw new ServletException(ERROR_CONVERTING_JSON_ARRAY_TO_XML, jsonException.getCause()); } responseContent.append(XML_RESULT_ROOT_END_TAG); _log.info("Flushing content : " + responseContent.toString()); Writer writer = response.getWriter(); writer.write(responseContent.toString()); writer.flush(); }
From source file:com.ewcms.component.rss.web.RssServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String encoding = DEFAULT_ENCODING; initResponseHeader(response, encoding); String value = getParameterValue(request, "id"); String rss = ""; try {/*ww w .j a v a 2s. c o m*/ int id = Integer.valueOf(value); String dns = request.getServerName(); rss = constructRss(id, dns); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?> "); builder.append("<rss version=\"2.0\">"); builder.append("</xml>"); rss = builder.toString(); } Writer writer = response.getWriter(); writer.write(rss); writer.flush(); }
From source file:bazaar4idea.command.BzrCommitCommand.java
private File saveCommitMessage() throws IOException { File systemDir = new File(PathManager.getSystemPath()); File tempFile = new File(systemDir, TEMP_FILE_NAME); Writer output = new BufferedWriter(new FileWriter(tempFile, false)); try {/*from w w w. j a v a 2s . co m*/ output.write(message); output.flush(); } finally { output.close(); } tempFile.deleteOnExit(); return tempFile; }
From source file:com.vmware.o11n.plugin.powershell.config.impl.HostConfigPersister.java
@Override protected byte[] config2Bytes(PowerShellHostConfig config) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Writer writer = new OutputStreamWriter(baos, "UTF-8"); newXStream().toXML(config, writer);// w ww. j a v a2 s . c om writer.flush(); return baos.toByteArray(); }
From source file:net.cit.tetrad.resource.CommandResource.java
@RequestMapping("/runServerStatus.do") public void runServerStatus(HttpServletResponse response, CommonDto dto) throws Exception { String serverStatusFromMongo = comandService.allServerStatus(dto.getDeviceCode()); response.setContentType("text/html;charset=utf-8"); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.setHeader("Cache-Control", "no-cache"); Writer writer = response.getWriter(); writer.write(serverStatusFromMongo); writer.flush(); }
From source file:com.github.jarscanner.XmlGenerator.java
public void generate() { Properties p = new Properties(); p.setProperty("resource.loader", "string"); p.setProperty("resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader"); Velocity.init(p);//from ww w .jav a 2 s . c o m Template template = getTemplate("com/github/jarscanner/jar-data.vm"); VelocityContext context = new VelocityContext(); context.put("duplicatesImpl", duplicatesImpl); context.put("duplicatesBridges", duplicatesBridges); try { Writer writer = new OutputStreamWriter(new FileOutputStream(outXml), "utf-8"); template.merge(context, writer); writer.flush(); writer.close(); } catch (IOException e) { LOG.error(e, e.getMessage()); } }
From source file:com.googlecode.pivotalchangelog.ReleasePlanGenerator.java
@Action public void process() throws TemplateException, IOException { LOGGER.debug(">> process"); Configuration cfg = new Configuration(); File templatesDirectory = new File("."); cfg.setDirectoryForTemplateLoading(templatesDirectory); cfg.setObjectWrapper(new DefaultObjectWrapper()); for (File entry : templatesDirectory.listFiles(new TemplatesFilenameFilter())) { Template template1 = cfg.getTemplate(entry.getName()); Map<String, NodeModel> root = new HashMap<String, NodeModel>(); root.put("doc", model); String outputFileName = entry.getName().replaceFirst(".ftl$", ""); Writer out = new OutputStreamWriter(new FileOutputStream(outputDir + outputFileName)); template1.process(root, out);// w w w . ja v a2s .c o m out.flush(); } LOGGER.debug("<< process"); }
From source file:net.cit.tetrad.resource.CommandResource.java
@RequestMapping("/runCommamd.do") public void loginView(HttpServletResponse response, CommonDto dto) throws Exception { Map<String, Object> serverStatusFromMongo = new HashMap<String, Object>(); serverStatusFromMongo = comandService.insertCommand(dto.getDeviceCode(), dto.getMemo()); List<Object> arrTotInfo = new ArrayList<Object>(); arrTotInfo.add(serverStatusFromMongo); PersonJson result = new PersonJson(); result.setAaData(arrTotInfo);/*from www .j a v a 2 s .co m*/ JSONObject jsonObject = JSONObject.fromObject(result); response.setContentType("text/html;charset=utf-8"); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.setHeader("Cache-Control", "no-cache"); Writer writer = response.getWriter(); writer.write(jsonObject.toString()); writer.flush(); }
From source file:com.centeractive.ws.server.endpoint.GenericSoapMessage.java
@Override public void writeTo(OutputStream outputStream) throws IOException { Writer writer = new OutputStreamWriter(outputStream, Charset.forName("UTF-8")); String message = XmlUtils.sourceToXmlString(source); writer.write(message);/*from w ww . j a v a 2s . c o m*/ writer.flush(); writer.close(); }