List of usage examples for java.io PrintStream print
public void print(Object obj)
From source file:org.chromium.base.PerfTraceEvent.java
/** * Dump all performance data we have saved up to the log. * Output as JSON for parsing convenience. *//* ww w .ja va 2 s . c om*/ private static void dumpPerf() { String json = sPerfTraceStrings.toString(); if (sOutputFile == null) { System.out.println(json); } else { try { PrintStream stream = new PrintStream(new FileOutputStream(sOutputFile, true)); try { stream.print(json); } finally { try { stream.close(); } catch (Exception ex) { Log.e("PerfTraceEvent", "Unable to close perf trace output file."); } } } catch (FileNotFoundException ex) { Log.e("PerfTraceEvent", "Unable to dump perf trace data to output file."); } } }
From source file:org.gradle.launcher.cli.CommandLineActionFactory.java
private static void showUsage(PrintStream out, CommandLineParser parser) { out.println();//from w ww . j a v a 2 s . co m out.print("USAGE: "); clientMetaData().describeCommand(out, "[option...]", "[task...]"); out.println(); out.println(); parser.printUsage(out); out.println(); }
From source file:kenh.xscript.ScriptUtils.java
/** * Debug method for <code>Element</code> * @param element/*from ww w . j a v a 2s .c o m*/ * @param level * @param stream */ private static final void debug_(Element element, int level, PrintStream stream) { String repeatStr = " "; String prefix = StringUtils.repeat(repeatStr, level); stream.print(prefix + "<" + element.getClass().getCanonicalName()); // Attribute output Map<String, String> attributes = element.getAttributes(); if (attributes != null && attributes.size() > 0) { Set<String> keys = attributes.keySet(); for (String key : keys) { stream.print(" " + key + "=\"" + attributes.get(key) + "\""); } } Vector<Element> children = element.getChildren(); String text = element.getText(); if ((children == null || children.size() == 0) && StringUtils.isBlank(text)) { stream.println("/>"); return; } else { stream.println(">"); // child elements if (children != null && children.size() > 0) { for (Element child : children) { debug_(child, level + 1, stream); } } // text/context if (StringUtils.isNotBlank(text)) { stream.println(prefix + repeatStr + "<![CDATA[" + text + "]]>"); } stream.println(prefix + "</" + element.getClass().getCanonicalName() + ">"); } }
From source file:io.hops.hopsworks.common.jobs.yarn.LogReader.java
/** * Keep calling this till you get a {@link EOFException} for getting logs of * all types for a single container./*from w w w . ja v a 2 s. co m*/ * * @param valueStream * @param out * @throws IOException */ public static void readAContainerLogsForALogType(DataInputStream valueStream, PrintStream out) throws IOException { byte[] buf = new byte[65535]; String fileType = valueStream.readUTF(); String fileLengthStr = valueStream.readUTF(); long fileLength = Long.parseLong(fileLengthStr); out.print("LogType: "); out.println(fileType); out.print("LogLength: "); out.println(fileLengthStr); out.println("Log Contents:"); long curRead = 0; long pendingRead = fileLength - curRead; int toRead = pendingRead > buf.length ? buf.length : (int) pendingRead; int len = valueStream.read(buf, 0, toRead); while (len != -1 && curRead < fileLength) { out.write(buf, 0, len); curRead += len; pendingRead = fileLength - curRead; toRead = pendingRead > buf.length ? buf.length : (int) pendingRead; len = valueStream.read(buf, 0, toRead); } out.println(""); }
From source file:edu.byu.softwareDist.manager.impl.SendEmailImpl.java
private static File saveTemplateToDisk(final FileSet fileSet) { File f = null;/* w w w. j a v a2 s . co m*/ PrintStream out = null; try { f = File.createTempFile("software-distribution-email-content." + fileSet.getFileSetId() + "-", ".vm"); out = new PrintStream(new FileOutputStream(f)); out.print(fileSet.getEmailContent()); out.flush(); return f; } catch (IOException e) { LOG.error("Error writing template to temporary file.", e); return null; } finally { if (f != null) { f.deleteOnExit(); } if (out != null) { out.close(); } } }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
private static void writeKey(PrintStream out, String value) { out.print(getJSONKey(value)); }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
private static void writeJSON(PrintStream out, Object value) { out.print(getJSON(value)); }
From source file:org.apache.nutch.ontology.jena.OntologyImpl.java
protected static void renderAnonymous(PrintStream out, Resource anon, String name) { String anonID = (String) m_anonIDs.get(anon.getId()); if (anonID == null) { anonID = "a-" + m_anonCount++; m_anonIDs.put(anon.getId(), anonID); }//www . j a va2 s.c o m out.print("Anonymous "); out.print(name); out.print(" with ID "); out.print(anonID); }
From source file:org.apache.nutch.ontology.jena.OntologyImpl.java
public static void renderClassDescription(PrintStream out, OntClass c, int depth) { indent(out, depth);// www . ja v a2 s .c om if (c.isRestriction()) { renderRestriction(out, (Restriction) c.as(Restriction.class)); } else { if (!c.isAnon()) { out.print("Class "); //renderURI( out, c.getModel(), c.getURI() ); out.print(c.getLocalName()); out.print(" ["); for (Iterator i = c.listLabels(null); i.hasNext();) { out.print(((Literal) i.next()).getString() + ", "); } out.print("] "); } else { renderAnonymous(out, c, "class"); } } }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
private static void writeDeletionInfo(PrintStream out, DeletionTime deletionTime) { out.print("\n{" + getDeletionInfo(deletionTime) + "}\n"); }