protected final void printCallInfo( final VariantContext vc, final double[] log10AlleleFrequencyPriors, final long runtimeNano, final AFCalcResult result) { printCallElement(vc, "type", "ignore", vc.getType()); int allelei = 0; for (final Allele a : vc.getAlleles()) printCallElement(vc, "allele", allelei++, a.getDisplayString()); for (final Genotype g : vc.getGenotypes()) printCallElement(vc, "PL", g.getSampleName(), g.getLikelihoodsString()); for (int priorI = 0; priorI < log10AlleleFrequencyPriors.length; priorI++) printCallElement(vc, "priorI", priorI, log10AlleleFrequencyPriors[priorI]); printCallElement(vc, "runtime.nano", "ignore", runtimeNano); printCallElement(vc, "log10PosteriorOfAFEq0", "ignore", result.getLog10PosteriorOfAFEq0()); printCallElement(vc, "log10PosteriorOfAFGt0", "ignore", result.getLog10PosteriorOfAFGT0()); for (final Allele allele : result.getAllelesUsedInGenotyping()) { if (allele.isNonReference()) { printCallElement(vc, "MLE", allele, result.getAlleleCountAtMLE(allele)); printCallElement( vc, "pNonRefByAllele", allele, result.getLog10PosteriorOfAFGt0ForAllele(allele)); } } callReport.flush(); }
/** * automatically generate non-existing help html files for existing commands in the CommandLoader * * @param cl the CommandLoader where you look for the existing commands */ public void createHelpText(CommandLoader cl) { File dir = new File((getClass().getResource("..").getPath())); dir = new File(dir, language); if (!dir.exists() && !dir.mkdirs()) { System.out.println("Failed to create " + dir.getAbsolutePath()); return; } for (String mnemo : cl.getMnemoList()) { if (!exists(mnemo)) { File file = new File(dir, mnemo + ".htm"); try { file.createNewFile(); BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(file)); PrintStream ps = new PrintStream(os); ps.println("<html>\n<head>\n<title>" + mnemo + "\n</title>\n</head>\n<body>"); ps.println("Command: " + mnemo.toUpperCase() + "<br>"); ps.println("arguments: <br>"); ps.println("effects: <br>"); ps.println("flags to be set: <br>"); ps.println("approx. clockcycles: <br>"); ps.println("misc: <br>"); ps.println("</body>\n</html>"); ps.flush(); ps.close(); } catch (IOException e) { System.out.println("failed to create " + file.getAbsolutePath()); } } } }
static void processFile(String fname, PrintStream out) throws IOException { System.err.println("Processing: " + fname); FileInputStream fio = new FileInputStream(new File(fname)); InputStreamReader fread = new InputStreamReader(fio, JetTest.encoding); BufferedReader fp = new BufferedReader(fread); StringBuffer buf = new StringBuffer(); int docno = 0, allsents = 0, processedsents = 0; while (true) { String line = fp.readLine(); // EOF or an empty line: the end of a Document. if (line == null || line.equals("")) { if (0 < buf.length()) { SGMLProcessor.allTags = true; Document doc = SGMLProcessor.sgmlToDoc(buf.toString(), (String[]) null); doc.setSGMLwrapMargin(0); System.err.println( "Doc-" + docno + ": sents=" + allsents + ", processed=" + processedsents); processDoc1(doc, docno); writeDoc1(doc, out); out.flush(); buf = new StringBuffer(); docno++; allsents = 0; processedsents = 0; } if (line == null) { break; } else { continue; } } if (line.startsWith("#")) { // "#" indicates a comment line. buf.append(line + "\n"); } else { allsents++; if (processedsents < MaxProcessSentences) { buf.append("<sentence>"); String[] words = line.split(" "); for (int i = 0; i < words.length; i++) { if (0 != words[i].length()) { buf.append("<token>" + words[i] + " </token>"); } } buf.append("</sentence>\n"); processedsents++; } } } fp.close(); fread.close(); fio.close(); return; }
/** * Closes down connections to the underlying process. This method will be used only if the * supporting Java Native Interface library could be loaded. */ private synchronized void native_close(PrintStream out) { try { in.close(); out.flush(); out.close(); } catch (IOException ioe) { } }
/** * Logs the event message to the output stream. * * @param out Stream to which the message is logged. * @param event Message to be logged. */ private void log(PrintStream out, String event) { if (null == log) { out.println(event); out.flush(); } else { log.log(event); } }
public static void main(String args[]) throws Exception { int testCases = Integer.parseInt(in.readLine()); for (int i = 0; i < testCases; i++) { char[] path = in.readLine().toCharArray(); output(path); out.println(); } out.flush(); }
protected static void writeReferencePositions(String filePath, ArrayList<Position> positions) throws FileNotFoundException { PrintStream os = new PrintStream(new File(filePath)); for (Position pos : positions) { os.format( "%.5f %.5f %.4f\n", pos.getLatitude().degrees, pos.getLongitude().degrees, pos.getElevation()); } os.flush(); }
/** * Render status using a given printer. * * @param status the IRunStatus to render to String * @param printer the IRunStatusPrinter to use (defaults to AJC_PRINTER if null) * @return the String rendering of the status, or "((IRunStatus) null)" if null */ public static String render(IRunStatus status, IRunStatusPrinter printer) { if (null == status) { return "((IRunStatus) null)"; } if (null == printer) { printer = RunUtils.AJC_PRINTER; } ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outStream); printer.printRunStatus(out, status); out.flush(); return outStream.toString(); }
public static void main(String args[]) throws Exception { StringTokenizer tokenizer = new StringTokenizer(in.readLine()); int n = Integer.parseInt(tokenizer.nextToken()), m = Integer.parseInt(tokenizer.nextToken()); Graph graph = new Graph(n, m); for (long i = 0; i < m; i++) { tokenizer = new StringTokenizer(in.readLine()); int from = Integer.parseInt(tokenizer.nextToken()), to = Integer.parseInt(tokenizer.nextToken()); graph.connect(from, to); } output(graph, n); out.println(); out.flush(); }
// made synchronized for 0087 // attempted to remove synchronized for 0136 to fix bug #775 (no luck tho) // http://dev.processing.org/bugs/show_bug.cgi?id=775 public synchronized void message(String s) { // System.out.println("M" + s.length() + ":" + s.trim()); // + "MMM" + s.length()); // this eats the CRLFs on the lines.. oops.. do it later // if (s.trim().length() == 0) return; // this is PApplet sending a message (via System.out.println) // that signals that the applet has been quit. if (s.indexOf(PApplet.EXTERNAL_STOP) == 0) { // System.out.println("external: quit"); if (editor != null) { // editor.internalCloseRunner(); // [091124] // editor.handleStop(); // prior to 0192 editor.internalCloseRunner(); // 0192 } return; } // this is the PApplet sending us a message that the applet // is being moved to a new window location if (s.indexOf(PApplet.EXTERNAL_MOVE) == 0) { String nums = s.substring(s.indexOf(' ') + 1).trim(); int space = nums.indexOf(' '); int left = Integer.parseInt(nums.substring(0, space)); int top = Integer.parseInt(nums.substring(space + 1)); // this is only fired when connected to an editor editor.setSketchLocation(new Point(left, top)); // System.out.println("external: move to " + left + " " + top); return; } // these are used for debugging, in case there are concerns // that some errors aren't coming through properly // if (s.length() > 2) { // System.err.println(newMessage); // System.err.println("message " + s.length() + ":" + s); // } // always shove out the message, since it might not fall under // the same setup as we're expecting sketchErr.print(s); // System.err.println("[" + s.length() + "] " + s); sketchErr.flush(); }
public static void main(String args[]) throws Exception { int testCases = Integer.parseInt(in.readLine()); for (int i = 0; i < testCases; i++) { StringTokenizer tokenizer = new StringTokenizer(in.readLine()); int n = Integer.parseInt(tokenizer.nextToken()); Party party = new Party(); for (int j = 0; j < n; j++) { Person person = new Person(j); tokenizer = new StringTokenizer(in.readLine()); while (tokenizer.hasMoreTokens()) person.add(Integer.parseInt(tokenizer.nextToken())); party.invite(person); } output(party); out.println(); } out.flush(); }
/** * Closes down connections to the underlying process. This method will be used only if the * supporting Java Native Interface library could not be loaded. */ private synchronized void pure_close(PrintStream out) { /* * Try to close this process for at least 30 seconds. */ for (int i = 0; i < 30; i++) { try { in.close(); err.close(); out.flush(); out.close(); } catch (IOException ioe) { } try { exit_code = p.waitFor(); p.destroy(); break; } catch (InterruptedException ie) { } try { Thread.sleep(1000); } catch (InterruptedException ie) { } } }
public HTTPResponse post(String host, int port, boolean isKeepAlive) { HTTPResponse httpRes = new HTTPResponse(); setConnection((isKeepAlive == true) ? HTTP.KEEP_ALIVE : HTTP.CLOSE); boolean isHeaderRequest = isHeadRequest(); OutputStream out = null; InputStream in = null; try { if (postSocket == null) postSocket = new Socket(host, port); out = postSocket.getOutputStream(); PrintStream pout = new PrintStream(out); pout.print(getHeader()); pout.print(HTTP.CRLF); boolean isChunkedRequest = isChunked(); String content = getContentString(); int contentLength = 0; if (content != null) contentLength = content.length(); if (0 < contentLength) { if (isChunkedRequest == true) { String chunSizeBuf = Long.toString(contentLength); pout.print(chunSizeBuf); pout.print(HTTP.CRLF); } pout.print(content); if (isChunkedRequest == true) pout.print(HTTP.CRLF); } if (isChunkedRequest == true) { pout.print("0"); pout.print(HTTP.CRLF); } pout.flush(); in = postSocket.getInputStream(); httpRes.set(in, isHeaderRequest); } catch (Exception e) { httpRes.setStatusCode(HTTPStatus.INTERNAL_SERVER_ERROR); } finally { if (isKeepAlive == false) { try { in.close(); } catch (Exception e) { } ; if (in != null) try { out.close(); } catch (Exception e) { } ; if (out != null) try { postSocket.close(); } catch (Exception e) { } ; postSocket = null; } } return httpRes; }
/** * ** Encodes the specified DBRecordKyes into XML and writes it to ** a specified PrintStream * ** @param out The PrintStream ** @param dbrk The list of DBRecordKeys */ public static void printXML(PrintStream out, DBRecordKey... dbrk) { if (out != null) { DBRecordKey.printXML(new PrintWriter(out), dbrk); out.flush(); } }
/** Finalizes output file. */ public void finished() { m_printstream.flush(); }
/** Starts main program with the specified arguments. */ public synchronized boolean run(String args[]) { ok = true; if (!parseArgs(args)) { return false; } try { if (cflag || uflag) { if (fname != null) { // The name of the zip file as it would appear as its own // zip file entry. We use this to make sure that we don't // add the zip file to itself. zname = fname.replace(File.separatorChar, '/'); if (zname.startsWith("./")) { zname = zname.substring(2); } } } if (cflag) { Manifest manifest = null; InputStream in = null; if (!Mflag) { if (mname != null) { in = new FileInputStream(mname); manifest = new Manifest(new BufferedInputStream(in)); } else { manifest = new Manifest(); } addVersion(manifest); addCreatedBy(manifest); if (isAmbiguousMainClass(manifest)) { if (in != null) { in.close(); } return false; } if (ename != null) { addMainClass(manifest, ename); } if (pname != null) { if (!addProfileName(manifest, pname)) { if (in != null) { in.close(); } return false; } } } OutputStream out; if (fname != null) { out = new FileOutputStream(fname); } else { out = new FileOutputStream(FileDescriptor.out); if (vflag) { // Disable verbose output so that it does not appear // on stdout along with file data // error("Warning: -v option ignored"); vflag = false; } } expand(null, files, false); create(new BufferedOutputStream(out, 4096), manifest); if (in != null) { in.close(); } out.close(); } else if (uflag) { File inputFile = null, tmpFile = null; FileInputStream in; FileOutputStream out; if (fname != null) { inputFile = new File(fname); tmpFile = createTempFileInSameDirectoryAs(inputFile); in = new FileInputStream(inputFile); out = new FileOutputStream(tmpFile); } else { in = new FileInputStream(FileDescriptor.in); out = new FileOutputStream(FileDescriptor.out); vflag = false; } InputStream manifest = (!Mflag && (mname != null)) ? (new FileInputStream(mname)) : null; expand(null, files, true); boolean updateOk = update(in, new BufferedOutputStream(out), manifest, null); if (ok) { ok = updateOk; } in.close(); out.close(); if (manifest != null) { manifest.close(); } if (ok && fname != null) { // on Win32, we need this delete inputFile.delete(); if (!tmpFile.renameTo(inputFile)) { tmpFile.delete(); throw new IOException(getMsg("error.write.file")); } tmpFile.delete(); } } else if (tflag) { replaceFSC(files); if (fname != null) { list(fname, files); } else { InputStream in = new FileInputStream(FileDescriptor.in); try { list(new BufferedInputStream(in), files); } finally { in.close(); } } } else if (xflag) { replaceFSC(files); if (fname != null && files != null) { extract(fname, files); } else { InputStream in = (fname == null) ? new FileInputStream(FileDescriptor.in) : new FileInputStream(fname); try { extract(new BufferedInputStream(in), files); } finally { in.close(); } } } else if (iflag) { genIndex(rootjar, files); } } catch (IOException e) { fatalError(e); ok = false; } catch (Error ee) { ee.printStackTrace(); ok = false; } catch (Throwable t) { t.printStackTrace(); ok = false; } out.flush(); err.flush(); return ok; }
static void writeDocRaw(Document doc, PrintStream out) throws IOException { out.println(doc.writeSGML(null).toString()); out.flush(); return; }
public static final void print(Object msg) { out.print(msg); out.flush(); }
public static void main(String argv[]) { try { BufferedReader buf1 = new BufferedReader(new FileReader("./index/pIndex")); FileOutputStream out = new FileOutputStream("finalindex"); PrintStream p = new PrintStream(out); String nline1, nline2, term1, term2, term3, term, t1, t2; StringBuffer sbuff = new StringBuffer(); StringBuffer sbuff1; long df, postings = 0, line = 0; String[] id; int flag = 0; while (true) { nline1 = buf1.readLine(); // System.out.println(nline1); if (nline1 == null) break; line++; String[] words = nline1.split(" "); String search_word = words[0]; char ch = search_word.charAt(0); // System.out.println("c"+ch); id = words[1].split(","); df = id.length; flag = 0; sbuff1 = new StringBuffer(); // System.out.println(df); if (df > 30000 && ((ch == 't') || ch == 'o' || ch == 'c')) { int count = 0; postings = 0; System.out.println("before df" + df + ";line" + line); // System.out.println("here\n"); while (count < df) { String temp1 = id[count]; String temp[] = temp1.split(":"); int t = Integer.parseInt(temp[1]); // System.out.println("t:"+t); if (t != 1) { if (flag == 0) { // System.out.println("here\n"); sbuff1.append(search_word); sbuff1.append(" "); sbuff1.append(temp1); flag = 1; } else { sbuff1.append(","); sbuff1.append(temp1); postings++; } } count++; } // System.out.println(sbuff1); System.out.println("postings size after:" + postings + ";line" + line); p.println(sbuff1.toString()); p.flush(); } else { p.println(nline1); p.flush(); } } } catch (IOException E) { } }
public String sendKommando(String kommando) throws IOException { System.out.println("send: " + kommando); ud.println(kommando); ud.flush(); // sørg for at data sendes til værten før vi læser svar return læsSvar(); }