public void save(File f) throws IOException { PrintStream ps = new PrintStream(new FileOutputStream(f)); String[] genes = genes(); Vector<Map<String, Double>> maps = new Vector<Map<String, Double>>(); for (int j = 0; j < coefs.size(); j++) { maps.add(coefs.get(j).geneValues(args.compare)); } ps.print("gene"); for (int i = 0; i < coefs.size(); i++) { ps.print(" " + keys.get(i)); } ps.println(); for (int i = 0; i < genes.length; i++) { ps.print(String.format("%s", genes[i])); for (int j = 0; j < coefs.size(); j++) { Map<String, Double> map = maps.get(j); Double value = map.containsKey(genes[i]) ? map.get(genes[i]) : null; ps.print(String.format(" %s", value != null ? String.format("%.2f", value) : "N/A")); } ps.println(); } ps.println(); ps.close(); }
private void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException { FileOutputStream fileOutputStream = new FileOutputStream(fileName); PrintStream printStream = new PrintStream(fileOutputStream); for (int i = 0; i < sql.length; i++) { printStream.println(sql[i] + getSqlDelimiter()); } }
public static void println(double[] p, PrintStream ps) { for (int i = 0; i < p.length; i++) { ps.print(i > 0 ? " " : ""); ps.print(String.format("%.2f", p[i])); } ps.println(); }
public static synchronized void printDebugMsg(PrintStream out) { if (DEBUG == false) { return; } StringBuffer msg = new StringBuffer(); msg.append("debug message in " + SimpleConnectionPool.class.getName()); msg.append("\r\n"); msg.append("total count is connection pool: " + getConnectionCount()); msg.append("\r\n"); msg.append("not used connection count: " + getNotUsedConnectionCount()); msg.append("\r\n"); msg.append("used connection, count: " + getUsedConnectionCount()); out.println(msg); Iterator iterator = m_usedUsedConnection.iterator(); while (iterator.hasNext()) { ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next(); wrapper.debugInfo.printStackTrace(out); } out.println(); }
/** * ** Prints all the default values from <code>RTKey</code> and {@link RTConfig} ** to the * specified <code>PrintStream</code>. Used for debugging/testing ** @param out The <code> * PrintStream</code> */ public static void printDefaults(PrintStream out) { /* print standard runtime entries */ Set<String> keyList = new OrderedSet<String>(); String keyGrp = null; for (Iterator<Entry> v = RTKey.getRuntimeEntryMap().values().iterator(); v.hasNext(); ) { Entry rtk = v.next(); if (rtk.isHelp()) { out.println(""); out.println("# ===== " + rtk.getHelp()); } else { Object dft = rtk.getDefault(); out.println("# --- " + rtk.getHelp()); out.println("# " + rtk.toString(dft)); String key = rtk.getKey(); keyList.add(key); if (!key.equals(CONFIG_FILE) && RTConfig.hasProperty(key)) { String val = RTConfig.getString(key, null); // if ((val != null) && ((dft == null) || !val.equals(dft.toString()))) { out.println(rtk.toString(val)); // } } } } /* orphaned entries */ RTProperties cmdLineProps = RTConfig.getConfigFileProperties(); if (cmdLineProps != null) { boolean orphanHeader = false; for (Iterator i = cmdLineProps.keyIterator(); i.hasNext(); ) { Object k = i.next(); if (!k.equals(COMMAND_LINE_CONF) && !keyList.contains(k)) { if (!orphanHeader) { out.println(""); out.println("# ===== Other entries"); orphanHeader = true; } Object v = cmdLineProps.getProperty(k, null); out.println(k + "=" + ((v != null) ? v : NULL_VALUE)); } } } /* final blank line */ out.println(""); }