List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:Main.java
/** * Run a command with the given data as input. *///from w w w . j a va 2 s. co 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. *//* ww w.jav 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: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);// w w w. j a v a 2s. 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.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); writer.flush();//from w w w .j a v a2 s . co m }
From source file:Main.java
public static void printIndent(PrintWriter out, int indent) { for (int i = 0; i < indent; i++) out.print(INDENT); }
From source file:Main.java
public static String toString(Throwable e) { StringWriter w = new StringWriter(); PrintWriter p = new PrintWriter(w); p.print(e.getClass().getName() + ": "); if (e.getMessage() != null) { p.print(e.getMessage() + "\n"); }//from ww w . j a v a 2s .c o m p.println(); try { e.printStackTrace(p); return w.toString(); } finally { p.close(); } }
From source file:Main.java
/** * Generates the XML open tag as follows: * <ul>//from w w w .j av a 2 s . c om * <li>If the isNull - <fieldName/> * <li>otherwise - <fieldName> a new line is inserted after this tag * if endWithNewLine = true * </ul> * * @param fieldName * @param isNull if true generates a self closing tag * @param pw * @param endWithNewLine if true then will add a new line after '>' tag * @throws Exception */ static public void writeXMLStart(String fieldName, boolean isNull, PrintWriter pw, boolean endWithNewLine) { pw.print('<'); pw.print(fieldName); if (isNull) { pw.println("/>"); } else { if (endWithNewLine) pw.println('>'); else pw.print('>'); } }
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
/** * Write a string to a file//w w w. j a va2s .com * @param content The string to write out * @param outputfile The file to which the string will be written */ public static void writeStringToFile(String content, File outputfile) { if (content != null && !content.equals("") && outputfile != null) { try { PrintWriter pwriter = new PrintWriter(new FileWriter(outputfile)); pwriter.print(content); pwriter.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.jmu.util.ResponseJsonUtils.java
public static void writeJSON(PrintWriter wirter, AjaxResponse json) { wirter.print(JSON.toJSONString(json)); wirter.flush();//from w w w . j a v a2s . c om wirter.close(); }