List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:de.unisb.cs.st.javaslicer.slicing.Slicer.java
private static void printHelp(Options options, PrintStream out) { out.println("Usage: " + Slicer.class.getSimpleName() + " [<options>] <file> <slicing criterion>"); out.println("where <file> is the input trace file"); out.println(" <slicing criterion> has the form <loc>[(<occ>)]:<var>[,<loc>[(<occ>)]:<var>]*"); out.println(" <options> may be one or more of"); HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printOptions(pw, 120, options, 5, 3); }
From source file:edu.msu.cme.rdp.readseq.utils.ResampleSeqFile.java
public static void selectOne(File infile, int num_of_seqs, int subregion_length, File outfile) throws IOException { IndexedSeqReader reader = new IndexedSeqReader(infile); PrintStream out = new PrintStream(new FileOutputStream(outfile)); Object[] seqIdSet = reader.getSeqIdSet().toArray(); HashSet<Integer> selectedIndexSet = randomSelectIndices(seqIdSet, num_of_seqs); // get the seq Sequence seq;/*from w ww .j a v a 2 s .c o m*/ if (subregion_length == 0) { for (int index : selectedIndexSet) { seq = reader.readSeq((String) seqIdSet[index]); out.println(">" + seqIdSet[index] + "\t" + seq.getDesc() + "\n" + seq.getSeqString()); } } else { for (int index : selectedIndexSet) { seq = reader.readSeq((String) seqIdSet[index]); if (seq.getSeqString().length() >= subregion_length) { int rdmIndex = (int) (Math .floor(Math.random() * (seq.getSeqString().length() - subregion_length))); out.println(">" + seqIdSet[index] + "\t" + seq.getDesc() + "\n" + seq.getSeqString().substring(rdmIndex, (rdmIndex + subregion_length))); } } } reader.close(); out.close(); }
From source file:com.bigdata.dastor.tools.SSTableExport.java
static void export(SSTableReader reader, PrintStream outs, String[] excludes) throws IOException { SSTableScanner scanner = reader.getScanner(INPUT_FILE_BUFFER_SIZE); Set<String> excludeSet = new HashSet(); if (excludes != null) excludeSet = new HashSet<String>(Arrays.asList(excludes)); outs.println("{"); while (scanner.hasNext()) { IteratingRow row = scanner.next(); if (excludeSet.contains(row.getKey().key)) continue; try {/*w w w . ja v a2 s . c o m*/ String jsonOut = serializeRow(row); outs.print(" " + jsonOut); if (scanner.hasNext()) outs.println(","); else outs.println(); } catch (IOException ioexcep) { System.err.println("WARNING: Corrupt row " + row.getKey().key + " (skipping)."); continue; } catch (OutOfMemoryError oom) { System.err.println("ERROR: Out of memory deserializing row " + row.getKey().key); continue; } } outs.println("}"); outs.flush(); }
From source file:hudson.plugins.trackplus.Updater.java
static boolean perform(AbstractBuild<?, ?> build, BuildListener listener) throws InterruptedException, IOException { PrintStream logger = listener.getLogger(); List<TrackplusIssue> issues = null; AbstractProject p = build.getProject(); try {//from ww w .ja va 2s .c om TrackplusSite site = TrackplusSite.get(build.getProject()); if (site == null) { logger.println(Messages.Updater_NoTrackplusSite()); build.setResult(Result.FAILURE); return true; } String rootUrl = Hudson.getInstance().getRootUrl(); if (rootUrl == null) { logger.println(Messages.Updater_NoHudsonUrl()); build.setResult(Result.FAILURE); return true; } Set<Integer> ids = findIssueIdsRecursive(build, site.getIssuePrefix(), listener); if (ids.isEmpty()) { if (debug) { logger.println("No Track+ issues found."); } return true; // nothing found here. } TrackplusSession session = null; try { session = site.createSession(); } catch (/*Service*/Exception e) { listener.getLogger().println(Messages.Updater_FailedToConnect()); e.printStackTrace(listener.getLogger()); } if (session == null) { logger.println(Messages.Updater_NoRemoteAccess()); build.setResult(Result.FAILURE); return true; } boolean doUpdate = false; if (site.updateTrackplusIssueForAllStatus) { doUpdate = true; } else { doUpdate = build.getResult().isBetterOrEqualTo(Result.UNSTABLE); } issues = getTrackplusIssues(ids, session, logger); build.getActions().add(new TrackplusBuildAction(build, issues)); if (doUpdate) { submitComments(build, logger, rootUrl, issues, session, site.recordScmChanges); } else { // this build didn't work, so carry forward the issues to the next build build.addAction(new TrackplusCarryOverAction(issues)); } } catch (Exception e) { logger.println("Error updating trackplus issues. Saving issues for next build.\n" + e); if (issues != null && !issues.isEmpty()) { // updating issues failed, so carry forward issues to the next build build.addAction(new TrackplusCarryOverAction(issues)); } } return true; }
From source file:com.fluidops.iwb.deepzoom.DZConvert.java
/** * Saves strings as text to the given file * @param lines the image to be saved/*from w ww . j a v a 2s .c om*/ * @param file the file to which it is saved */ private static void saveText(Vector lines, File file) throws IOException { PrintStream ps = null; try { FileOutputStream fos = new FileOutputStream(file); ps = new PrintStream(fos); for (int i = 0; i < lines.size(); i++) ps.println((String) lines.elementAt(i)); } catch (IOException e) { throw new IOException("Unable to write to text file: " + file); } finally { IOUtils.closeQuietly(ps); } }
From source file:de.oth.keycloak.util.CheckParams.java
private static CommandLine checkCommandline(String[] args, PrintStream printStream) { Options options = getCommandLineOptions(); CommandLineParser parser = new GnuParser(); try {// ww w . j av a 2 s . co m CommandLine ret = parser.parse(options, args); if (ret.getOptions().length == 0 || ret.hasOption(CONF_HELP)) { printCommandLineHelp(options); return null; } return ret; } catch (ParseException e) { printStream.println(e.getMessage()); printCommandLineHelp(options); return null; } }
From source file:eu.europeana.uim.sugarcrmclient.internal.helpers.ClientUtils.java
/** * This method marshals the contents of a JAXB Element and outputs the * results to the Karaf output console.// w w w . j a v a 2s . com * * @param out * the (Karaf console) printwriter * @param jibxObject */ public static void logMarshalledObjectOsgi(PrintStream out, Object jibxObject) { try { String xmlContent = unmarshallObject(jibxObject); out.println("==========================================="); StringBuffer sb = new StringBuffer("Soap Ouput for Class: "); sb.append(jibxObject.getClass().getSimpleName()); out.println(sb.toString()); out.println(xmlContent); out.println("==========================================="); } catch (JiBXException e) { logger.error(e.getMessage()); } }
From source file:com.xylocore.copybook.runtime.internal.AbstractCopybookGenerator.java
private static void generateFooter(PrintStream aOutputStream) { aOutputStream.println("}"); }
From source file:com.aptana.core.epl.downloader.RepositoryStatusHelper.java
private static void deeplyPrint(Throwable t, PrintStream strm, boolean stackTrace, int level) { if (t instanceof CoreException) deeplyPrint((CoreException) t, strm, stackTrace, level); else {/*from w w w . jav a 2 s. co m*/ appendLevelString(strm, level); if (stackTrace) t.printStackTrace(strm); else { strm.println(t.toString()); Throwable cause = t.getCause(); if (cause != null) { strm.print("Caused by: "); //$NON-NLS-1$ deeplyPrint(cause, strm, stackTrace, level); } } } }
From source file:Main.java
/** * Performs the actual recursive dumping of a DOM tree to a given * <CODE>PrintStream</CODE>. Note that dump is intended to be a detailed * debugging aid rather than pretty to look at. * //from w w w. j a v a2s.co m * @param out The <CODE>PrintStream</CODE> to write to. * @param node The <CODE>Node</CODE> under consideration. * @param indent The level of indentation. * @see #dump(Node) * @see #dump(PrintStream, Node) * @since TFP 1.0 */ private static void doDump(PrintStream out, final Node node, int indent) { if (node != null) { for (int index = 0; index < indent; ++index) out.write(' '); switch (node.getNodeType()) { case Node.DOCUMENT_NODE: { Document document = (Document) node; out.println("DOCUMENT:"); doDump(out, document.getDoctype(), indent + 1); doDump(out, document.getDocumentElement(), indent + 1); break; } case Node.DOCUMENT_TYPE_NODE: { DocumentType type = (DocumentType) node; out.println("DOCTYPE: [" + "name=" + format(type.getName()) + "," + "publicId=" + format(type.getPublicId()) + "," + "systemId=" + format(type.getSystemId()) + "]"); break; } case Node.ELEMENT_NODE: { Element element = (Element) node; out.println("ELEMENT: [" + "ns=" + format(element.getNamespaceURI()) + "," + "name=" + format(element.getLocalName()) + "]"); NamedNodeMap attrs = element.getAttributes(); for (int index = 0; index < attrs.getLength(); ++index) doDump(out, attrs.item(index), indent + 1); for (Node child = element.getFirstChild(); child != null;) { doDump(out, child, indent + 1); child = child.getNextSibling(); } break; } case Node.ATTRIBUTE_NODE: { Attr attr = (Attr) node; out.println("ATTRIBUTE: [" + "ns=" + format(attr.getNamespaceURI()) + "," + "prefix=" + format(attr.getPrefix()) + "," + "name=" + format(attr.getLocalName()) + "," + "value=" + format(attr.getNodeValue()) + "]"); break; } case Node.TEXT_NODE: { Text text = (Text) node; out.println("TEXT: [" + format(text.getNodeValue()) + "]"); for (Node child = text.getFirstChild(); child != null;) { doDump(out, child, indent + 1); child = child.getNextSibling(); } break; } case Node.CDATA_SECTION_NODE: { CDATASection data = (CDATASection) node; out.println("CDATA: [" + format(data.getNodeValue()) + "]"); break; } case Node.COMMENT_NODE: { Comment comm = (Comment) node; out.println("COMMENT: [" + format(comm.getNodeValue()) + "]"); break; } default: out.println("UNKNOWN: [type=" + node.getNodeType() + "]"); break; } } }