List of usage examples for java.io Writer flush
public abstract void flush() throws IOException;
From source file:com.linuxbox.enkive.message.MultiPartHeaderImpl.java
@Override public void pushReconstitutedEmail(Writer output) throws IOException { output.write(printMultiPartHeader()); output.flush(); }
From source file:com.cloudera.lib.wsrs.JSONMapProvider.java
@Override public void writeTo(Map map, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException { Writer writer = new OutputStreamWriter(outputStream); JSONObject.writeJSONString(map, writer); writer.write(ENTER);//ww w . j a v a 2s . c o m writer.flush(); }
From source file:com.cloudera.lib.wsrs.JSONProvider.java
@Override public void writeTo(JSONStreamAware jsonStreamAware, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException { Writer writer = new OutputStreamWriter(outputStream); jsonStreamAware.writeJSONString(writer); writer.write(ENTER);/*from w ww . j a v a 2 s . co m*/ writer.flush(); }
From source file:com.asakusafw.dmdl.thundergate.emitter.RecordLockDdlEmitter.java
/** * Appends DDL contents into the target stream. * @param stream the target stream//from w ww. jav a 2 s. c om * @throws IOException if failed to append to the stream by I/O error */ public void appendTo(OutputStream stream) throws IOException { Writer writer = new OutputStreamWriter(stream, RecordLockDdlEmitter.ENCODING); appendTo(writer); writer.flush(); }
From source file:com.googlecode.jsfFlex.phaseListener.RawServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { Collection<? extends Object> objectCollection = null; try {//w w w.j a v a 2 s . c o m objectCollection = (Collection<? 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 (objectCollection != null) { StringBuilder responseContent = new StringBuilder(); for (Object currObj : objectCollection) { responseContent.append(currObj.toString()); } _log.info("Flushing content : " + responseContent.toString()); Writer writer = response.getWriter(); writer.write(responseContent.toString()); writer.flush(); } }
From source file:com.googlecode.jsfFlex.phaseListener.XMLServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { Collection<? extends Object> objectCollection = null; try {// w w w . j a v a 2 s .c o m objectCollection = (Collection<? 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(XML_CONTENT_TYPE); StringBuilder responseContent = new StringBuilder(); responseContent.append(XML_HEAD); responseContent.append(XML_RESULT_ROOT_START_TAG); if (objectCollection != null) { for (Object currObj : objectCollection) { responseContent.append(XML_VALUE_START_TAG); responseContent.append(currObj.toString()); responseContent.append(XML_VALUE_END_TAG); } } 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.counter.web.CounterServlet.java
private void reponseCount(HttpServletRequest request, HttpServletResponse response, final String encoding, final int count) throws IOException { initResponseHeader(response, encoding); String callback = getParameterValue(request, CALLBACK_PARAMETER_NAME); String value;/* w ww . j a va 2 s . co m*/ if (callback == null) { value = "alert('?');"; } else { value = String.format("%s(\"%d\");", callback, count); } Writer writer = response.getWriter(); writer.write(value); writer.flush(); }
From source file:com.googlecode.jsfFlex.phaseListener.ObjectServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { JSONObject methodResult = null;//from w w w . j av a 2s.c o m try { methodResult = JSONObject.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); try { responseContent.append(JSONConverter.convertJSONObjectToXMLString(methodResult)); } catch (JSONException jsonException) { throw new ServletException(ERROR_CONVERTING_JSON_OBJECT_TO_XML, jsonException.getCause()); } _log.info("Flushing content : " + responseContent.toString()); Writer writer = response.getWriter(); writer.write(responseContent.toString()); writer.flush(); }
From source file:com.joliciel.talismane.extensions.standoff.StandoffWriter.java
void process(Map<String, Object> model, Writer writer) { try {//from w w w . ja v a 2 s .c om template.process(model, writer); writer.flush(); } catch (TemplateException te) { LogUtils.logError(LOG, te); throw new RuntimeException(te); } catch (IOException ioe) { LogUtils.logError(LOG, ioe); throw new RuntimeException(ioe); } }
From source file:com.comcast.cmb.test.tools.CNSTestingUtils.java
public static String generateMessageJson(String message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); Writer writer = new PrintWriter(out); JSONWriter jw = new JSONWriter(writer); try {//w w w. ja va2s. c o m jw = jw.object(); jw.key("Token").value(message); jw.endObject(); writer.flush(); } catch (Exception e) { return ""; } return out.toString(); }