List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:Main.java
/** * Whenever you'd need to print a configuration node and/or its children. * * @param root the root node to print.//from w w w. ja v a2 s.co m * @param out the print stream that should be used to outpu * @param recurse boolean * @param prefix String */ public static void printChildElements(Element root, PrintStream out, boolean recurse, String prefix) { out.print(prefix + "<" + root.getNodeName()); NamedNodeMap attrs = root.getAttributes(); Node node; for (int i = 0; i < attrs.getLength(); i++) { node = attrs.item(i); out.print(" " + node.getNodeName() + "=\"" + node.getNodeValue() + "\""); } out.println(">"); String data = getText(root); if (data != null && data.trim().length() > 0) out.println(prefix + "\t" + data); data = getCData(root); if (data != null && data.trim().length() > 0) out.println(prefix + "\t<![CDATA[" + data + "]]>"); NodeList nodes = root.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { if (recurse) printChildElements((Element) node, out, recurse, prefix + "\t"); else out.println(prefix + node.getNodeName()); } } out.println(prefix + "</" + root.getNodeName() + ">"); }
From source file:ml.shifu.guagua.hadoop.io.GuaguaOptionsParser.java
/** * Print the usage message for generic command-line options supported. * /*from w w w.j a v a2 s . c om*/ * @param out * stream to print the usage message to. */ public static void printGenericCommandUsage(PrintStream out) { out.println("Generic options supported are"); out.println("-conf <configuration file> specify an application configuration file"); out.println("-D <property=value> use value for given property"); out.println("-fs <local|namenode:port> specify a namenode"); out.println("-jt <local|jobtracker:port> specify a job tracker"); out.println( "-files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster"); out.println( "-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath."); out.println( "-archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines."); out.println("-i <input folder or input file> specify input folder or input file."); out.println("-z <comma separated list of zookeeper servers> specify zookeeper servers."); out.println("-w <full qualified class name> specify worker class name."); out.println("-m <full qualified class name> specify master class name."); out.println("-mr <full qualified class name> specify master result class name."); out.println("-wr <full qualified class name> specify worker result class name."); out.println("-c <number> specify maximal iteration count."); out.println("-n <job name> specify job name."); out.println("-inputformat <inputformat class name> specify inputformat class name.\n"); out.println("The general command line syntax is"); out.println("bin/hadoop command [genericOptions] [commandOptions]\n"); }
From source file:com.wandrell.example.swss.client.console.ConsoleClient.java
/** * Prints the client help screen.//from ww w . j a va 2 s. c o m * * @param output * output where the information will be printed */ private static final void printHelp(final PrintStream output) { output.println("========================================================================"); output.println("Pick an option. Write 'exit' to close the client."); output.println(); output.println("The server should be running at the default URI for this client to work."); output.println("Check the server log for the SOAP messages traces."); output.println("========================================================================"); }
From source file:com.wandrell.example.swss.client.console.ConsoleClient.java
/** * Prints all the available options in the main menu to the console client. * * @param output//from ww w.j a va2 s.co m * output where the options will be printed */ private static final void printClientOptions(final PrintStream output) { output.println("Choose a security configuration:"); output.println(); output.println("1.- Unsecure"); output.println("2.- Plain password (XWSS)"); output.println("3.- Plain password (WSS4J)"); output.println("4.- Digested password (XWSS)"); output.println("5.- Digested password (WSS4J)"); output.println("6.- Signature (XWSS)"); output.println("7.- Signature (WSS4J)"); output.println("8.- Encryption (XWSS)"); output.println("9.- Encryption (WSS4J)"); }
From source file:com.liferay.blade.cli.util.Prompter.java
private static Optional<Boolean> _getBooleanAnswer(String questionWithPrompt, InputStream inputStream, PrintStream printStream, Optional<Boolean> defaultAnswer) { Optional<Boolean> answer = null; try (CloseShieldInputStream closeShieldInputStream = new CloseShieldInputStream(inputStream); Scanner scanner = new Scanner(closeShieldInputStream)) { while ((answer == null) || !answer.isPresent()) { printStream.println(questionWithPrompt); String readLine = null; while (((answer == null) || !answer.isPresent()) && !Objects.equals(answer, defaultAnswer) && scanner.hasNextLine()) { readLine = scanner.nextLine(); if (readLine != null) { readLine = readLine.toLowerCase(); switch (readLine.trim()) { case "y": case "yes": answer = Optional.of(true); break; case "n": case "no": answer = Optional.of(false); break; default: if (defaultAnswer.isPresent()) { answer = defaultAnswer; } else { printStream.println("Unrecognized input: " + readLine); continue; }/*from w w w . j av a2 s.c om*/ break; } } else { answer = defaultAnswer; } } } } catch (IllegalStateException ise) { throw new RuntimeException(ise); } catch (Exception exception) { if (defaultAnswer.isPresent()) { answer = defaultAnswer; } } return answer; }
From source file:com.opengamma.analytics.financial.model.finitedifference.applications.PDEUtilityTools.java
public static void printSurface(final String name, final PDEFullResults1D res, final PrintStream out) { final int tNodes = res.getNumberTimeNodes(); final int xNodes = res.getNumberSpaceNodes(); out.println(name); for (int i = 0; i < xNodes; i++) { final double k = res.getSpaceValue(i); out.print("\t" + k); }/*from w w w . j a v a2 s.c o m*/ out.print("\n"); for (int j = 0; j < tNodes; j++) { final double t = res.getTimeValue(j); out.print(t); for (int i = 0; i < xNodes; i++) { out.print("\t" + res.getFunctionValue(i, j)); } out.print("\n"); } out.print("\n"); }
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 .j av a2 s . com * * @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:de.unisb.cs.st.javaslicer.traceResult.TraceResult.java
private static void printHelp(Options options, PrintStream out) { out.println("Usage: " + TraceResult.class.getSimpleName() + " [<options>] <file>"); out.println("where <file> is the input trace file, and <options> may be one or more of"); HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printOptions(pw, 120, options, 5, 3); out.println();/*from w w w .j ava 2s.c o m*/ out.println("The output of the trace itself will have six fields:"); out.println(" - Nr: just a continuously increasing counter, starting at 0"); out.println( " - intern Nr: this is the instance number, which will always be identical when iterating the trace"); out.println(" - Location: Class name, method name and line number of the instruction"); out.println(" - Dep: Stack depth of the instruction (1 for outermost stack frames, like main)"); out.println( " - OccNr: The occurence number of that single instruction (how often was it visited before)"); out.println(" - Instruction: Textual representation of the bytecode instruction"); out.println( "Remember that the trace is output backwards. This means nr, intern nr and occNr are counting from the end of the trace."); out.println("The intern Nr may have gaps if specific instructions have been filtered out (see -f option)."); out.println( "By default, labels that have been inserted during instrumentation (so called additionals) are filtered out."); }
From source file:edu.msu.cme.rdp.unifrac.Unifrac.java
public static void printResults(PrintStream out, UnifracResult unifracResult, String label) { List<MCSample> labels = new ArrayList(unifracResult.getSamples()); Collections.sort(labels, new Comparator<MCSample>() { public int compare(MCSample o1, MCSample o2) { return o1.getSampleName().compareTo(o2.getSampleName()); }/*from w w w . jav a 2 s.c om*/ }); out.println(label); for (int i = 0; i < labels.size(); i++) { for (int j = i + 1; j < labels.size(); j++) { int row = unifracResult.getSamples().indexOf(labels.get(i)); int col = unifracResult.getSamples().indexOf(labels.get(j)); out.println(labels.get(i) + "-" + labels.get(j) + "\t" + format.format(unifracResult.getUnifracMatrix()[row][col]) + " "); } } }
From source file:com.zimbra.cs.session.WaitSetValidator.java
private static void printError(String text) { PrintStream ps = System.err; try {//w ww. j a v a2 s . com BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(ps, "UTF-8")); writer.write(text + "\n"); writer.flush(); } catch (UnsupportedEncodingException e) { ps.println(text); } catch (IOException e) { ps.println(text); } }