List of usage examples for java.io PrintWriter println
public void println(Object x)
From source file:com.espertech.esper.epl.join.plan.NStreamOuterQueryPlanBuilder.java
/** * Returns textual presentation of stream-substream relationships. * @param streamsJoinedPerStream is the tree-like structure of stream-substream * @return textual presentation//from www . ja v a 2s . c o m */ public static String print(Map<Integer, int[]> streamsJoinedPerStream) { StringWriter buf = new StringWriter(); PrintWriter printer = new PrintWriter(buf); for (int stream : streamsJoinedPerStream.keySet()) { int[] substreams = streamsJoinedPerStream.get(stream); printer.println("stream " + stream + " : " + Arrays.toString(substreams)); } return buf.toString(); }
From source file:net.metanotion.sqlc.SqlcPhp.java
public static int makeMethod(final PrintWriter writer, final SQLMethod m, final Statement qe, final int level, final int[] gensym, final int[] braces, final boolean retValue) { final int stmt = gensym[0]; gensym[0]++;// ww w. j a va 2s .c o m /* writer.println("\t\t\ttry (final java.sql.PreparedStatement _" + stmt + " = _0.prepareStatement(\"" + StringEscapeUtils.escapeJava(qe.sql.trim()) + "\")) {"); */ writer.println( "\t\t\t$_" + stmt + " = $_0.prepare(\"" + StringEscapeUtils.escapeJava(qe.sql.trim()) + "\");"); //braces[0] = braces[0] + 1; for (final SQLSetter s : qe.setters) { int i = 0; for (int j = 0; j < m.pList.length; j++) { if (s.name.equals(m.pList[j])) { i = j + 1; break; } } writer.println("\t\t\t" + s.setStatic("$_" + stmt, "_" + i) + ";"); } writer.println("\t\t\t$_" + stmt + ".execute();"); return -1; }
From source file:MainClass.java
public static void premain(final Instrumentation inst) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { PrintWriter out = new PrintWriter(System.err); ThreadMXBean tb = ManagementFactory.getThreadMXBean(); out.printf("Current thread count: %d%n", tb.getThreadCount()); out.printf("Peak thread count: %d%n", tb.getPeakThreadCount()); List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); for (MemoryPoolMXBean pool : pools) { MemoryUsage peak = pool.getPeakUsage(); out.printf("Peak %s memory used: %,d%n", pool.getName(), peak.getUsed()); out.printf("Peak %s memory reserved: %,d%n", pool.getName(), peak.getCommitted()); }/*from www . j a v a2 s .com*/ Class[] loaded = inst.getAllLoadedClasses(); out.println("Loaded classes:"); for (Class c : loaded) out.println(c.getName()); out.close(); } catch (Throwable t) { System.err.println("Exception in agent: " + t); } } }); }
From source file:com.zimbra.common.util.TemplateCompiler.java
private static void printDataLine(PrintWriter out, String s) { out.print("\tbuffer[_i++] = data"); Matcher part = RE_PARAM_PART.matcher(s); while (part.find()) { String name = part.group(1); String args = part.group(2); out.print("[\""); out.print(name);// w w w .j a va 2 s .co m out.print("\"]"); if (args != null) { out.print(args); } } out.println(";"); }
From source file:haflow.component.mahout.logistic.RunLogistic.java
static void mainToOutput(String[] args) throws Exception { if (parseArgs(args)) { if (!showAuc && !showConfusion && !showScores) { showAuc = true;//w w w . j a v a 2 s . co m showConfusion = true; } //PrintWriter output=new PrintWriter(new FileOutputStream(outputFile),true); PrintWriter output = new PrintWriter(HdfsUtil.writeHdfs(outputFile), true); PrintWriter acc_output = new PrintWriter(HdfsUtil.writeHdfs(accurateFile), true); Auc collector = new Auc(); LogisticModelParameters lmp = LogisticModelParameters.loadFrom(HdfsUtil.open(modelFile)); CsvRecordFactory csv = lmp.getCsvRecordFactory(); OnlineLogisticRegression lr = lmp.createRegression(); BufferedReader in = new BufferedReader(new InputStreamReader(HdfsUtil.open(inputFile))); String line = in.readLine(); csv.firstLine(line); line = in.readLine(); if (showScores) { output.println("\"target\",\"model-output\",\"log-likelihood\""); } while (line != null) { Vector v = new SequentialAccessSparseVector(lmp.getNumFeatures()); int target = csv.processLine(line, v); double score = lr.classifyScalar(v); if (showScores) { output.printf(Locale.ENGLISH, "%d,%.3f,%.6f%n", target, score, lr.logLikelihood(target, v)); } collector.add(target, score); line = in.readLine(); } if (showAuc) { acc_output.printf(Locale.ENGLISH, "AUC , %.2f%n", collector.auc()); } if (showConfusion) { Matrix m = collector.confusion(); acc_output.printf(Locale.ENGLISH, "confusion, [[%.1f %.1f], [%.1f %.1f]]%n", m.get(0, 0), m.get(1, 0), m.get(0, 1), m.get(1, 1)); m = collector.entropy(); acc_output.printf(Locale.ENGLISH, "entropy, [[%.1f %.1f], [%.1f %.1f]]%n", m.get(0, 0), m.get(1, 0), m.get(0, 1), m.get(1, 1)); } output.close(); acc_output.close(); } }
From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java
public static void writeInputDatumToFile(PrintWriter writer, String label, DoubleMatrix1D vector) throws IOException { for (int i = 0; i < vector.size(); i++) { if (!Double.isNaN(vector.get(i))) { writer.write(vector.get(i) + " "); } else {//w w w . ja va 2 s. co m writer.write("? "); } } writer.println(label); }
From source file:com.jdo.CloudContactUtils.java
public static void updateSingle(CloudContactEnty cn, PersistenceManager pm, PrintWriter pr) { Profile p = cn.getProfile();//w w w . j a v a2s . c om String ss = p.getServiceTimings(); HashMap<String, String> seMap = new HashMap<String, String>(); if (pr != null) { pr.println("Service: " + ss); } if (ss != null && !ss.isEmpty()) { String[] ssA = ss.split(","); for (String sa : ssA) { String sa1[] = sa.trim().split("="); seMap.put(sa1[0], sa1[1]); } String dateS = getDay(); if (pr != null) { pr.println("Day : " + dateS); //pr.println("Day : " +new Date().toString()); TimeZone.getTimeZone("Asia").getOffset(Calendar.getInstance().getTimeInMillis()); } String start = seMap.get(dateS + "_start"); String end = seMap.get(dateS + "_end"); if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) { try { float f1 = Float.parseFloat(start); float f2 = Float.parseFloat(end); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Calcutta")); float f = Float.parseFloat(cal.get(Calendar.HOUR_OF_DAY) + "." + cal.get(Calendar.MINUTE)); //float offset=getOffset("Asia/Calcutta"); //f=f+offset; if (pr != null) { pr.println("Current Time : " + f); } if (f > f1 && f < f2) { if (!"in".equals(cn.getService())) { cn.setService("in"); if (pm != null) pm.makePersistent(cn); if (pr != null) { pr.println("Done Inside Inservice"); } } } else { if (!"out".equals(cn.getService())) { cn.setService("out"); if (pm != null) pm.makePersistent(cn); if (pr != null) { pr.println("Done Inside Outofservice"); } } } } catch (Exception e) { e.printStackTrace(); if (pr != null) { pr.println(e.getMessage()); } } } } }
From source file:io.warp10.worf.WorfInteractive.java
private static String readInteger(ConsoleReader reader, PrintWriter out, String prompt) { try {/*from w ww . j a v a 2s. com*/ String inputString = readInputString(reader, out, prompt); if (NumberUtils.isNumber(inputString)) { return inputString; } if (InetAddresses.isInetAddress(inputString)) { return inputString; } out.println("Error, " + inputString + " is not a number"); } catch (Exception exp) { if (WorfCLI.verbose) { exp.printStackTrace(); } out.println("Error, unable to read the host. error=" + exp.getMessage()); } return null; }
From source file:net.metanotion.sqlc.SQLC.java
public static int makeMethod(final PrintWriter writer, final SQLMethod m, final TXWrap qe, final int level, final int[] gensym, final int[] braces, final boolean retValue) { writer.println("\t\ttry {"); writer.println("\t\t\t_0.setAutoCommit(false);"); makeMethod(writer, m, qe.expr, level + 1, gensym, braces, retValue); if (!(qe.expr instanceof VoidWrap)) { writer.println("\t\t\treturn _" + (gensym[0] - 1) + ";"); }// ww w. j av a 2 s . co m while (braces[0] > 0) { writer.println("}"); braces[0]--; } writer.println("\t\t} catch (final java.sql.SQLException sqle) {"); writer.println("\t\t\t_0.rollback();"); writer.println("\t\t\tthrow sqle;"); writer.println("\t\t} finally {"); writer.println("\t\t\t_0.setAutoCommit(true);"); writer.println("\t\t}"); return -1; }
From source file:Gen.java
public static void embedRScripts() throws Exception { {/*from w w w.j av a2 s . com*/ File embedScriptFile = new File(GEN_ROOT_SRC + FILE_SEPARATOR + "bootstrap.R"); PrintWriter pw = new PrintWriter(new FileWriter(embedScriptFile)); pw.println(embedScriptBuffer); pw.close(); } for (Iterator<?> iter = DirectJNI._rPackageInterfacesHash.keySet().iterator(); iter.hasNext();) { String className = (String) iter.next(); String packageName = className.substring(className.lastIndexOf('.') + 1); File packScriptFile = new File( GEN_ROOT_SRC + FILE_SEPARATOR + className.replace('.', FILE_SEPARATOR) + ".R"); PrintWriter pw = new PrintWriter(new FileWriter(packScriptFile)); pw.println( packageEmbedScriptHashMap.get(packageName) != null ? packageEmbedScriptHashMap.get(packageName) : "## No Init Required"); pw.close(); } }