private static void showThreads(PrintStream pw, ThreadGroup g, Thread current) { int nthreads = g.activeCount(); pw.println("\nThread Group = " + g.getName() + " activeCount= " + nthreads); Thread[] tarray = new Thread[nthreads]; int n = g.enumerate(tarray, false); for (int i = 0; i < n; i++) { Thread thread = tarray[i]; ClassLoader loader = thread.getContextClassLoader(); String loaderName = (loader == null) ? "Default" : loader.getClass().getName(); Thread.State state = thread.getState(); long id = thread.getId(); pw.print(" " + id + " " + thread.getName() + " " + state + " " + loaderName); if (thread == current) pw.println(" **** CURRENT ***"); else pw.println(); } int ngroups = g.activeGroupCount(); ThreadGroup[] garray = new ThreadGroup[ngroups]; int ng = g.enumerate(garray, false); for (int i = 0; i < ng; i++) { ThreadGroup nested = garray[i]; showThreads(pw, nested, current); } }
public void saveFile(File f) throws IOException { PrintStream ps = new PrintStream(new FileOutputStream(f)); ps.print("ID"); for (Column c : cols) { ps.print(String.format("\t%s", c.id)); } ps.println(); for (int i = 0; i < samples.size(); i++) { ps.print(samples.get(i)); for (int j = 0; j < cols.size(); j++) { Float ff = cols.get(j).values.get(i); if (ff == null) { ps.print("\tnull"); } else { ps.print(String.format("\t%.2f", ff)); } } ps.println(); if (i > 0) { if (i % 100 == 0) { System.out.print("."); System.out.flush(); } } } System.out.println(); ps.close(); }
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(); }
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(); }
@Test public void canFollowLogfile() throws IOException { File tempFile = File.createTempFile("commons-io", "", new File(System.getProperty("java.io.tmpdir"))); tempFile.deleteOnExit(); System.out.println("Temp file = " + tempFile.getAbsolutePath()); PrintStream log = new PrintStream(tempFile); LogfileFollower follower = new LogfileFollower(tempFile); List<String> lines; // Empty file: lines = follower.newLines(); assertEquals(0, lines.size()); // Write two lines: log.println("Line 1"); log.println("Line 2"); lines = follower.newLines(); assertEquals(2, lines.size()); assertEquals("Line 2", lines.get(1)); // Write one more line: log.println("Line 3"); lines = follower.newLines(); assertEquals(1, lines.size()); assertEquals("Line 3", lines.get(0)); // Write one and a half line and finish later: log.println("Line 4"); log.print("Line 5 begin"); lines = follower.newLines(); assertEquals(1, lines.size()); // End last line and start a new one: log.println(" end"); log.print("Line 6 begin"); lines = follower.newLines(); assertEquals(1, lines.size()); assertEquals("Line 5 begin end", lines.get(0)); // End last line: log.println(" end"); lines = follower.newLines(); assertEquals(1, lines.size()); assertEquals("Line 6 begin end", lines.get(0)); // A line only missing a newline: log.print("Line 7"); lines = follower.newLines(); assertEquals(0, lines.size()); log.println(); lines = follower.newLines(); assertEquals(1, lines.size()); assertEquals("Line 7", lines.get(0)); // Delete: log.close(); lines = follower.newLines(); assertEquals(0, lines.size()); }
/** * dump the message to a PrintStream. The output is sorta XML, intended to be easily parsed. <br> * Each component is responsible for its own dump function, ISOMsg just calls dump on every valid * field. * * @param p - print stream * @param indent - optional indent string */ public void dump(PrintStream p, String indent) { ISOComponent c; p.print(indent + "<" + XMLPackager.ISOMSG_TAG); switch (direction) { case INCOMING: p.print(" direction=\"incoming\""); break; case OUTGOING: p.print(" direction=\"outgoing\""); break; } if (fieldNumber != -1) p.print(" " + XMLPackager.ID_ATTR + "=\"" + fieldNumber + "\""); p.println(">"); String newIndent = indent + " "; if (getPackager() != null) { p.println(newIndent + "<!-- " + getPackager().getDescription() + " -->"); } if (header instanceof Loggeable) ((Loggeable) header).dump(p, newIndent); for (int i = 0; i <= maxField; i++) { if ((c = (ISOComponent) fields.get(i)) != null) c.dump(p, newIndent); // // Uncomment to include bitmaps within logs // // if (i == 0) { // if ((c = (ISOComponent) fields.get (new Integer (-1))) != null) // c.dump (p, newIndent); // } // } p.println(indent + "</" + XMLPackager.ISOMSG_TAG + ">"); }
/** * Generates XML description of the OD.<br> * If the print stream is specified, then XML buffer is written to the stream. * * @param out print stream. * @throws IOException */ public void xmlDump(PrintStream out) throws IOException { if (out == null) out = System.out; out.print("<od begin=\"" + origin.getId() + "\" end=\"" + destination.getId() + "\">\n"); out.print("<PathList>\n"); for (int i = 0; i < pathList.size(); i++) pathList.get(i).xmlDump(out); out.print("</PathList>\n</od>\n"); return; }
/** * Prints a linkage specification block to a stream. * * @param spec The block to print. * @param stream The stream on which to print the block. */ public static void defaultPrint(LinkageSpecification spec, OutputStream stream) { PrintStream p = new PrintStream(stream); p.print("extern \""); p.print(spec.calling_convention); p.print("\"\n{\n"); Tools.printlnList(spec.children, stream); p.print("}"); }
public void writeMetadata(final PrintStream s) { s.print(" Evaluation type: "); for (final Eval e : evals) s.print(e.getEvalName() + " "); s.println(); s.println(" Test files:"); for (final String f : corpusFiles) s.println(" " + f); if (filterLength > 0) s.println(" Filter test files by len: " + filterLength); // if (numSent > 0) // s.println(" Num test sentences: " + numSent); s.println(" Test file type: " + testFileType); }
// printzcvn // printzcvn prints teh values of ZCVN as neeed by routines public static void printzcvn() { out.print(" ZCVN = "); for (int i = 0; i < 4; i++) { if (flag[i]) { out.print("1"); } else { out.print("0"); } } out.println(); }
/** * Prints a __builtin_offsetof expression to a stream. * * @param expr The expression to print. * @param stream The stream on which to print the expression. */ public static void defaultPrint(OffsetofExpression expr, OutputStream stream) { PrintStream p = new PrintStream(stream); p.print("__builtin_offsetof"); p.print("("); Tools.printListWithSeparator(expr.specs, stream, " "); p.print(","); expr.getExpression().print(stream); p.print(")"); }
public static void printKeyValues(String k, List<String> v, PrintStream ps) { ps.print(k + " => "); boolean first = true; for (String val : v) { if (!first) { ps.print(", "); } first = false; ps.print(val); } ps.println(); }
/** Adds a new file entry to the ZIP output stream. */ void addFile(ZipOutputStream zos, File file) throws IOException { String name = file.getPath(); boolean isDir = file.isDirectory(); if (isDir) { name = name.endsWith(File.separator) ? name : (name + File.separator); } name = entryName(name); if (name.equals("") || name.equals(".") || name.equals(zname)) { return; } else if ((name.equals(MANIFEST_DIR) || name.equals(MANIFEST_NAME)) && !Mflag) { if (vflag) { output(formatMsg("out.ignore.entry", name)); } return; } long size = isDir ? 0 : file.length(); if (vflag) { out.print(formatMsg("out.adding", name)); } ZipEntry e = new ZipEntry(name); e.setTime(file.lastModified()); if (size == 0) { e.setMethod(ZipEntry.STORED); e.setSize(0); e.setCrc(0); } else if (flag0) { crc32File(e, file); } zos.putNextEntry(e); if (!isDir) { copy(file, zos); } zos.closeEntry(); /* report how much compression occurred. */ if (vflag) { size = e.getSize(); long csize = e.getCompressedSize(); out.print(formatMsg2("out.size", String.valueOf(size), String.valueOf(csize))); if (e.getMethod() == ZipEntry.DEFLATED) { long ratio = 0; if (size != 0) { ratio = ((size - csize) * 100) / size; } output(formatMsg("out.deflated", String.valueOf(ratio))); } else { output(getMsg("out.stored")); } } }
/** * Prints an array access expression to a stream. * * @param expr The array access to print. * @param stream The stream on which to print the array access. */ public static void defaultPrint(ArrayAccess expr, OutputStream stream) { PrintStream p = new PrintStream(stream); Iterator<Traversable> iter = expr.children.iterator(); iter.next().print(stream); while (iter.hasNext()) { p.print("["); Traversable o = iter.next(); o.print(stream); p.print("]"); } }
/** * Determines if the given configuration is currently running. If any of the configurations are * currently stuck in the queue, it is logged. * * @param execution Contains information about the general build, including the listener used to * log queue blockage. * @param configuration The configuration being checked to see if it's running. * @param mutableWhyMap Mutable map used to track the reasons a configuration is stuck in the * queue. This prevents duplicate reasons from flooding the logs. * @return True if the build represented by the given configuration is currently running or stuck * in the queue. False if the build has finished running. */ private boolean isBuilding( MatrixBuild.MatrixBuildExecution execution, MatrixConfiguration configuration, Map<String, String> mutableWhyMap) { MatrixRun build = configuration.getBuildByNumber(execution.getBuild().getNumber()); if (build != null) { return build.isBuilding(); } Queue.Item queueItem = configuration.getQueueItem(); if (queueItem != null) { String why = queueItem.getWhy(); String key = queueItem.task.getFullDisplayName() + " " + queueItem.id; String oldWhy = mutableWhyMap.get(key); if (why == null) { mutableWhyMap.remove(key); } if (why != null && !why.equals(oldWhy)) { mutableWhyMap.put(key, why); BuildListener listener = execution.getListener(); PrintStream logger = listener.getLogger(); logger.print( "Configuration " + ModelHyperlinkNote.encodeTo(configuration) + " is still in the queue: "); queueItem.getCauseOfBlockage().print(listener); // this is still shown on the same line } } return true; }
public static void xlsl() { out.println("xlsl instruction"); // XLSL1 shifts AC left one bit, sets/resets the flags // if AC is negative, carry bit will be true if ((short) AC < 0) { flag[1] = true; } else { flag[1] = false; } // setting overflow flag // if it changes sign, overflow if ((short) (0xFFFF & AC) > 0 && (short) ((0xFFFF & AC) << 1) < 0) { flag[2] = true; } else if ((short) (0xFFFF & AC) < 0 && (short) ((0xFFFF & AC) << 1) > 0) { flag[2] = true; } else { flag[2] = false; } AC += -(0xFFFF & AC) + (0xFFFF & AC << 1); out.println(0xFFFF & AC); // set the flags setFlagsXRotS(); out.print("xlsl1 AC = " + AC); printzcvn(); }
// rl // rl rotates AC left one bit, sets/resets all flags public static void rl() { out.println("rl instruction"); // RL1 rotates AC left one bit, sets/resets the flags // if AC is negative, carry bit will be true if ((byte) AC < 0) { flag[1] = true; } else { flag[1] = false; } // setting overflow flag // if it changes sign, overflow if ((byte) (0xFF & AC) > 0 && (byte) ((0xFF & AC) << 1) < 0) { flag[2] = true; } else if ((byte) (0xFF & AC) < 0 && (byte) ((0xFF & AC) << 1) > 0) { flag[2] = true; } else { flag[2] = false; } AC += -(0xFF & AC) + (0xFF & AC << 1); // if there is a carried bit, set the LSB to 1 if (flag[1]) { AC++; } // set the remaining flags setFlagsRotS(); out.print("rl1 AC = " + (byte) (0xFF & AC)); printzcvn(); }
public static void ddd() { for (int j = 1; j < dept.length; j++) { String i; if (j < 10) i = "0" + j; else i = "" + j; o.print( "<tr><td>" + dept[j] + "</td>" + "<td><input readonly='readonly' size=16 type=\"text\" name=\"" + i + "1\" id=\"" + i + "1\" value=\"<%=time[" + j + ']' + "[1]%>\" /></td>" + "<td><input readonly='readonly' size=16 type=\"text\" name=\"" + i + "2\" id=\"" + i + "2\" value=\"<%=time[" + j + ']' + "[2]%>\" /></td>" + "<td><input readonly='readonly' size=16 type=\"text\" name=\"" + i + "3\" id=\"" + i + "3\" value=\"<%=time[" + j + ']' + "[3]%>\" /></td>" + "<td><input readonly='readonly' size=16 type=\"text\" name=\"" + i + "4\" id=\"" + i + "4\" value=\"<%=time[" + j + ']' + "[4]%>\" /></td>" + "<td><input readonly='readonly' size=16 type=\"text\" name=\"" + i + "5\" id=\"" + i + "5\" value=\"<%=time[" + j + ']' + "[5]%>\" /></td>" + "<td><input readonly='readonly' size=16 type=\"text\" name=\"" + i + "6\" id=\"" + i + "6\" value=\"<%=time[" + j + ']' + "[6]%>\" /></td>" + "</tr>\n"); } }
// inac // inac increments the accumulator public static void inac() { out.println("inac instruction"); // INAC1 increment the value in AC by 1, setting/resetting flags // as appropriate if (((byte) (AC) < 0) && ((byte) (AC + 1) >= 0)) { flag[1] = true; } else { flag[1] = false; } if ((byte) (AC) == 127) { flag[2] = true; } else { flag[2] = false; } if ((byte) (AC) == -1) { AC -= 0xFF & AC; } else { AC++; } // set other flags if ((byte) AC == 0) { flag[0] = true; } else { flag[0] = false; } if ((byte) AC < 0) { flag[3] = true; } else { flag[3] = false; } out.print("inac1 AC = " + (byte) (0xFF & AC)); printzcvn(); }
public static void xlsr() { out.println("xlsr instruction"); // LSR1 shifts AC right one bit, sets/resets all flags if ((short) AC < 0) { if (((short) AC * -1) % 2 == 1) { flag[1] = true; } else { flag[1] = false; } } else if ((short) AC % 2 == 1) { flag[1] = true; } else { flag[1] = false; } int conv; conv = AC & 0xFFFF; conv >>>= 1; // setting overflow flag // if it changes sign, overflow if ((short) (0xFFFF & AC) > 0 && (short) conv < 0) { flag[2] = true; } else if ((short) (0xFFFF & AC) < 0 && (short) conv > 0) { flag[2] = true; } else { flag[2] = false; } AC += -(0xFFFF & AC) + conv; // set the flags setFlagsXRotS(); out.print("xlsr1 AC = " + AC); printzcvn(); }
public static void xinac() { out.println("xinac instruction"); // XINAC1 increment the value in AC by 1, setting/resetting flags // as appropriate if ((AC < 0) && (AC + 1 >= 0)) { flag[1] = true; } else { flag[1] = false; } if (AC > 0 && (short) (AC + 1) < 0) { flag[2] = true; } else { flag[2] = false; } AC++; // set other flags if (AC == 0) { flag[0] = true; } else { flag[0] = false; } if (AC < 0) { flag[3] = true; } else { flag[3] = false; } out.print("xinac1 AC = " + AC); printzcvn(); }
// add // add adds the value in R with AC, and places the value in AC public static void add() { out.println("add instruction"); // ADD1 adds R into AC, and sets the flags as appropriate add1(); out.print("add1 AC = " + (byte) (0xFF & AC) + " R = " + (byte) (0xFF & R)); printzcvn(); }
public static void xadd() { out.println("xadd instruction"); // XADD1 adds R into AC, and sets the flags as appropriate xadd1(); out.print("xadd1 AC = " + AC + " R = " + R); printzcvn(); }
public void run(PrintStream out, Debugger dbg) { CDebugger cdbg = dbg.getCDebugger(); if (cdbg != null) { List l = cdbg.getLoadObjectList(); for (Iterator itr = l.iterator(); itr.hasNext(); ) { LoadObject lo = (LoadObject) itr.next(); out.print(lo.getBase() + "\t"); out.print(lo.getSize() / 1024 + "K\t"); out.println(lo.getName()); } } else { if (getDebugeeType() == DEBUGEE_REMOTE) { out.println("remote configuration is not yet implemented"); } else { out.println("not yet implemented (debugger does not support CDebugger)!"); } } }
private static void writeTokensCode( PrintStream o, int nTokens, List<String> tokenName, List<Integer> tokenType, List<String> nameOf) throws Exception { int i; o.println(" public static final String[] tokenNames = new String[] {"); o.print("\"" + nameOf.get(0) + "\""); for (i = 1; i < nameOf.size(); i++) { o.print(", \"" + nameOf.get(i) + "\""); } o.println("};"); for (i = 0; i < nTokens; i++) { o.println(" public static final int " + tokenName.get(i) + "=" + tokenType.get(i) + ";"); } }
/** * Set current pen color. Default to black if null. * * @param c new pen color. */ public void setColor(Color c) { if (c != null) { m_localGraphicsState.setColor(c); if (m_psGraphicsState.getColor().equals(c)) { return; } m_psGraphicsState.setColor(c); } else { m_localGraphicsState.setColor(Color.black); m_psGraphicsState.setColor(getColor()); } m_printstream.print(getColor().getRed() / 255.0); m_printstream.print(" "); m_printstream.print(getColor().getGreen() / 255.0); m_printstream.print(" "); m_printstream.print(getColor().getBlue() / 255.0); m_printstream.println(" setrgbcolor"); }
private static boolean askYesOrNo(PrintStream out, String prompt) throws IOException { out.print(prompt); BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); String str; str = rd.readLine(); return str.equalsIgnoreCase("y"); // NOI18N }
public void sendTekst(String kommando, String data) throws IOException { Socket df = skafDataforbindelse(); PrintStream dataUd = new PrintStream(df.getOutputStream()); sendKommando(kommando); // f.eks STOR fil.txt dataUd.print(data); dataUd.close(); df.close(); læsSvar(); }
// jv // jv jumps to the given address if v is 1 public static void jv() { out.println("jv instruction"); if (flag[2]) { jumper("jv"); } else { // increment past the uneeded address PC += 2; out.print("jv1 PC = " + ((int) 0xFFFF & PC)); printzcvn(); } }
public static void sub() { out.println("sub instruction"); // SUB1 complements R, and calls the add() routine R = (short) -R; add1(); // set R back to its original value R = (short) -R; out.print("sub1 AC = " + (byte) (0xFF & AC)); printzcvn(); }