List of usage examples for java.io PrintWriter flush
public void flush()
From source file:Main.java
/** * Run a command with the given data as input. *//*from www . j a v a 2 s . c o m*/ public static void systemIn(String command, String data) throws Exception { String cmd[] = new String[3]; cmd[0] = System.getProperty("SHELL", "/bin/sh"); cmd[1] = "-c"; cmd[2] = command; Process p = Runtime.getRuntime().exec(cmd); PrintWriter w = new PrintWriter(p.getOutputStream()); w.print(data); w.flush(); w.close(); p.waitFor(); }
From source file:Main.java
/** * Run a command with the given data as input. *//*from w w w . java 2 s .c o m*/ public static void systemIn(String command, String data) throws Exception { String[] cmd = new String[3]; cmd[0] = System.getProperty("SHELL", "/bin/sh"); cmd[1] = "-c"; cmd[2] = command; Process p = Runtime.getRuntime().exec(cmd); PrintWriter w = new PrintWriter(p.getOutputStream()); w.print(data); w.flush(); w.close(); p.waitFor(); }
From source file:com.jjtree.utilities.JResponse.java
public static void sendJson(HttpServletResponse response, JSONObject json) throws IOException { PrintWriter writer = response.getWriter(); writer.print(json);//from w w w . jav a 2 s. co m writer.flush(); }
From source file:Main.java
public static String getStackTraceString(Throwable tr) { if (tr == null) { return ""; }/*w w w . j a v a 2s . c o m*/ // This is to reduce the amount of log spew that apps do in the non-error // condition of the network being unavailable. Throwable t = tr; while (t != null) { if (t instanceof UnknownHostException) { return ""; } t = t.getCause(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); tr.printStackTrace(pw); pw.flush(); return sw.toString(); }
From source file:com.bluepandora.therap.donatelife.jsonsender.SendJsonData.java
public static void sendJsonData(HttpServletRequest request, HttpServletResponse response, JSONObject object) { response.setContentType("application/json"); System.out.println(object);//from w w w . ja v a2 s .c o m try { PrintWriter out = response.getWriter(); out.print(object); out.flush(); } catch (IOException io) { io.printStackTrace(); } catch (Exception error) { error.printStackTrace(); } }
From source file:com.dianping.lion.util.ThrowableUtils.java
public static String extractStackTrace(Throwable t) { StringWriter me = new StringWriter(); PrintWriter pw = new PrintWriter(me); t.printStackTrace(pw);// w ww. j a v a 2s. c om pw.flush(); return me.toString(); }
From source file:com.dianping.lion.util.ThrowableUtils.java
public static String extractStackTrace(Throwable t, int maxLen) { StringWriter me = new StringWriter(); PrintWriter pw = new PrintWriter(me); t.printStackTrace(pw);/*from www . jav a 2 s .co m*/ pw.flush(); return StringUtils.substring(me.toString(), 0, maxLen); }
From source file:com.jjtree.utilities.JResponse.java
public static void sendErrorMessage(int errorCode, String errorMessage, HttpServletResponse response) throws JSONException, IOException { JSONObject resultObject = new JSONObject(); resultObject.put("errorCode", errorCode); resultObject.put("errorMessage", errorMessage); PrintWriter writer = response.getWriter(); writer.print(resultObject);// w w w .j a v a 2 s . co m writer.flush(); }
From source file:com.jmu.util.ResponseJsonUtils.java
public static void writeJSON(PrintWriter wirter, String json) { wirter.print(json); wirter.flush(); wirter.close(); }
From source file:Main.java
public static void writeToFile(String fileName, String xml) throws IOException { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true), 1024)); out.println(xml);/*from w ww . j a v a 2 s .c o m*/ out.flush(); out.close(); }