Java Code Examples for java.io.PrintStream#println()
The following examples show how to use
java.io.PrintStream#println() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerTool.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public boolean processCommand( String[] cmdArgs, ORB orb, PrintStream out ) { if ((cmdArgs.length == 2) && cmdArgs[0].equals( "-applicationName" )) { String str = (String)cmdArgs[1] ; try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME )); try { int result = repository.getServerID( str ) ; out.println() ; out.println(CorbaResourceUtil.getText("servertool.getserverid2", str, Integer.toString(result))); out.println() ; } catch (ServerNotRegistered e) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } } catch (Exception ex) { ex.printStackTrace() ; } return commandDone ; } else return parseError ; }
Example 2
Source File: AwkParser.java From vscrawler with Apache License 2.0 | 6 votes |
private void dump(PrintStream ps, int lvl) { StringBuffer spaces = new StringBuffer(); for (int i = 0; i < lvl; i++) { spaces.append(' '); } ps.println(spaces + toString()); if (ast1 != null) { ast1.dump(ps, lvl + 1); } if (ast2 != null) { ast2.dump(ps, lvl + 1); } if (ast3 != null) { ast3.dump(ps, lvl + 1); } if (ast4 != null) { ast4.dump(ps, lvl + 1); } }
Example 3
Source File: InputAgent.java From jaamsim with Apache License 2.0 | 6 votes |
/** * Prints selected outputs for the simulation run to stdout or a file. * @param simTime - simulation time at which the outputs are printed. */ public static void printRunOutputs(JaamSimModel simModel, PrintStream outStream, double simTime) { Simulation simulation = simModel.getSimulation(); // Write the selected outputs StringBuilder sb = new StringBuilder(); for (int i = 0; i < simulation.getRunOutputList().getListSize(); i++) { StringProvider samp = simulation.getRunOutputList().getValue().get(i); String str; try { str = samp.getNextString(simTime); } catch (Exception e) { str = e.getMessage(); } if (i > 0) sb.append("\t"); sb.append(str); } outStream.println(sb.toString()); // Terminate the outputs if (simModel.isLastRun()) { outStream.close(); outStream = null; } }
Example 4
Source File: Server.java From cxf with Apache License 2.0 | 6 votes |
@Override public void call(JavaPairRDD<String, Integer> rdd) { if (!rdd.collectAsMap().isEmpty()) { String jobId = null; PrintStream printStream = null; for (Map.Entry<String, Integer> entry : rdd.collectAsMap().entrySet()) { String value = entry.getKey() + " : " + entry.getValue(); if (jobId == null) { int index = value.indexOf(':'); jobId = value.substring(0, index); printStream = "oneway".equals(jobId) ? System.out : streamOut; } printStream.println(value); } printStream.println(jobId + ":" + "<batchEnd>"); } }
Example 5
Source File: StackableRuntimeException.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Prints the stack trace to the specified stream. * * @param stream the output stream. */ public void printStackTrace(final PrintStream stream) { super.printStackTrace(stream); if (getParent() != null) { stream.println("ParentException: "); getParent().printStackTrace(stream); } }
Example 6
Source File: JschUtil.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
public static String getDaemonProcessId(Session session, String daemon) throws JSchException, IOException { String command = PID_COMMAND_PREFIX + daemon + PID_COMMAND_SUFFIX; session.connect(); Channel channel = session.openChannel("shell"); channel.connect(); OutputStream os = channel.getOutputStream(); InputStream is = channel.getInputStream(); PrintStream ps = new PrintStream(os, true); String pid = ""; try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { ps.println(command); for (String line = br.readLine(); line != null; line = br.readLine()) { if (line.contains(daemon) && !line.contains("awk ")) { pid = line.split("\\s+")[1]; } } } LOGGER.debug(" exit status - " + channel.getExitStatus() + ", daemon = " + daemon + ", PID = " + pid); if (channel != null && channel.isConnected()) { channel.disconnect(); } if (session != null && session.isConnected()) { session.disconnect(); } return pid; }
Example 7
Source File: Assembler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Print the byte codes */ public void listing(PrintStream out) { out.println("-- listing --"); for (Instruction inst = first ; inst != null ; inst = inst.next) { out.println(inst.toString()); } }
Example 8
Source File: CommandLineActionFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private static void showUsage(PrintStream out, CommandLineParser parser) { out.println(); out.print("USAGE: "); clientMetaData().describeCommand(out, "[option...]", "[task...]"); out.println(); out.println(); parser.printUsage(out); out.println(); }
Example 9
Source File: Assembler.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Print the byte codes */ public void listing(PrintStream out) { out.println("-- listing --"); for (Instruction inst = first ; inst != null ; inst = inst.next) { out.println(inst.toString()); } }
Example 10
Source File: TxtExporter.java From Design-Patterns-and-SOLID-Principles-with-Java with MIT License | 5 votes |
private void printStrings(PrintStream out, List<String> strings) { out.print(LEFT_BORDER); out.print(IntStream.range(0, strings.size()) .mapToObj(i -> { String fmt = String.format("%%%ss", widths.get(i)); return String.format(fmt, strings.get(i)); }) .collect(Collectors.joining(SEPARATOR))); out.print(RIGHT_BORDER); out.println(); }
Example 11
Source File: TestLibrary.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void printEnvironment(PrintStream out) { out.println("-------------------Test environment----------" + "---------"); for(Enumeration<?> keys = System.getProperties().keys(); keys.hasMoreElements();) { String property = (String) keys.nextElement(); out.println(property + " = " + getProperty(property, null)); } out.println("---------------------------------------------" + "---------"); }
Example 12
Source File: Util.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static void dumpAddresses(SctpChannel channel, PrintStream printStream) throws IOException { Set<SocketAddress> addrs = channel.getAllLocalAddresses(); printStream.println("Local Addresses: "); for (Iterator<SocketAddress> it = addrs.iterator(); it.hasNext(); ) { InetSocketAddress addr = (InetSocketAddress)it.next(); printStream.println("\t" + addr); } }
Example 13
Source File: GPlusUserActivityProvider.java From streams with Apache License 2.0 | 5 votes |
/** * Retrieve recent activity from a list of accounts. * @param args args * @throws Exception Exception */ public static void main(String[] args) throws Exception { Preconditions.checkArgument(args.length >= 2); String configfile = args[0]; String outfile = args[1]; File file = new File(configfile); assert (file.exists()); Config conf = ConfigFactory.parseFileAnySyntax(file, ConfigParseOptions.defaults().setAllowMissing(false)); StreamsConfigurator.addConfig(conf); StreamsConfiguration streamsConfiguration = StreamsConfigurator.detectConfiguration(); GPlusUserActivityProviderConfiguration config = new ComponentConfigurator<>(GPlusUserActivityProviderConfiguration.class).detectConfiguration(); GPlusUserActivityProvider provider = new GPlusUserActivityProvider(config); Gson gson = new Gson(); PrintStream outStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outfile))); provider.prepare(config); provider.startStream(); do { Uninterruptibles.sleepUninterruptibly(streamsConfiguration.getBatchFrequencyMs(), TimeUnit.MILLISECONDS); for (StreamsDatum datum : provider.readCurrent()) { String json; if (datum.getDocument() instanceof String) { json = (String) datum.getDocument(); } else { json = gson.toJson(datum.getDocument()); } outStream.println(json); } } while ( provider.isRunning()); provider.cleanUp(); outStream.flush(); }
Example 14
Source File: UsageGenerator.java From tlaplus with MIT License | 4 votes |
public static void displayUsage(final PrintStream ps, final String commandName, final String version, final String commandShortSummary, final String commandDescription, final List<List<Argument>> commandVariants, final List<String> tips, final char valuedArgumentsSeparator) { ps.println(); ps.println(generateSectionHeader(NAME)); ps.println('\t' + commandName + " - " + commandShortSummary + ((version != null) ? (" - " + version) : "") + "\n\n"); final String boldName = markupWord(commandName, true); final HashSet<Argument> arguments = new HashSet<>(); ps.println(generateSectionHeader(SYNOPSIS)); for (final List<Argument> variant : commandVariants) { ps.println("\t" + generateCommandForVariant(boldName, variant, arguments, valuedArgumentsSeparator)); } ps.println(); final String commandNameRegex = commandName + "(\\)|\\s|$)"; final Pattern p = Pattern.compile(commandNameRegex); final Matcher m = p.matcher(commandDescription); final String markedUpDescription; if (m.find()) { final StringBuilder sb = new StringBuilder(); if (m.start() > 0) { sb.append(commandDescription.substring(0, m.start())); } sb.append(boldName).append(m.group(1)); int lastEnd = m.end(); while (m.find()) { sb.append(commandDescription.substring(lastEnd, m.start())).append(boldName).append(m.group(1)); lastEnd = m.end(); } sb.append(commandDescription.substring(lastEnd, commandDescription.length())); markedUpDescription = sb.toString(); } else { markedUpDescription = commandDescription; } ps.println(generateSectionHeader(DESCRIPTION)); ps.println("\t" + markedUpDescription.replaceAll("(\\r\\n|\\r|\\n)", "\n\t")); ps.println(); final List<Argument> orderedArguments = new ArrayList<>(arguments); Collections.sort(orderedArguments, NAME_COMPARATOR); ps.println(generateSectionHeader(OPTIONS)); for (final Argument arg : orderedArguments) { if (arg.expectsValue() || arg.isOptional() || (!arg.expectsValue() && arg.isDashArgument())) { ps.println(generateOptionText(arg, valuedArgumentsSeparator)); } } ps.println(); if ((tips != null) && (tips.size() > 0)) { ps.println(generateSectionHeader(TIPS)); for (final String tip : tips) { ps.println("\t" + tip.replaceAll("(\\r\\n|\\r|\\n)", "\n\t") + "\n"); } } }
Example 15
Source File: InfoCommand.java From clue with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private static void toString(Object[] info, PrintStream out) throws IOException { FieldInfo finfo = (FieldInfo) info[0]; List<Terms> termList = (List<Terms>) info[1]; out.println("name:\t\t" + finfo.name); out.println("docval_type:\t" + finfo.getDocValuesType()); out.println("norms:\t\t" + finfo.hasNorms()); IndexOptions indexOptions = finfo.getIndexOptions(); if (indexOptions != null) { out.println("index_options:\t" + finfo.getIndexOptions().name()); } out.println("payloads:\t" + finfo.hasPayloads()); out.println("vectors:\t" + finfo.hasVectors()); out.println("attributes:\t" + finfo.attributes().toString()); if (termList != null) { long numTerms = 0L; long docCount = 0L; long sumDocFreq = 0L; long sumTotalTermFreq = 0L; for (Terms t : termList) { if (t != null) { numTerms += t.size(); docCount += t.getDocCount(); sumDocFreq += t.getSumDocFreq(); sumTotalTermFreq += t.getSumTotalTermFreq(); } } if (numTerms < 0) { numTerms = -1; } if (docCount < 0) { docCount = -1; } if (sumDocFreq < 0) { sumDocFreq = -1; } if (sumTotalTermFreq < 0) { sumTotalTermFreq = -1; } out.println("num_terms:\t" + numTerms); out.println("doc_count:\t" + docCount); out.println("sum_doc_freq:\t" + sumDocFreq); out.println("sum_total_term_freq:\t" + sumTotalTermFreq); } }
Example 16
Source File: JarReorder.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private void run(String args[]) { int arglen = args.length; int argpos = 0; // Look for "-o outputfilename" option if (arglen > 0) { if (arglen >= 2 && args[0].equals("-o")) { try { out = new PrintStream(new FileOutputStream(args[1])); } catch (FileNotFoundException e) { System.err.println("Error: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } argpos += 2; arglen -= 2; } else { System.err.println("Error: Illegal arg count"); System.exit(1); } } else { out = System.out; } // Should be 2 or more args left if (arglen <= 2) { usage(); System.exit(1); } // Read the ordered set of files to be included in rt.jar. // Read the set of files/directories to be excluded from rt.jar. String classListFile = args[argpos]; String excludeListFile = args[argpos + 1]; argpos += 2; arglen -= 2; // Create 2 lists and a set of processed files List<String> orderList = readListFromFile(classListFile, true); List<String> excludeList = readListFromFile(excludeListFile, false); Set<String> processed = new HashSet<String>(); // Create set of all files and directories excluded, then expand // that list completely Set<String> excludeSet = new HashSet<String>(excludeList); Set<String> allFilesExcluded = expand(null, excludeSet, processed); // Indicate all these have been processed, orderList too, kept to end. processed.addAll(orderList); // The remaining arguments are names of files/directories to be included // in the jar file. Set<String> inputSet = new HashSet<String>(); for (int i = 0; i < arglen; ++i) { String name = args[argpos + i]; name = cleanPath(new File(name)); if ( name != null && name.length() > 0 && !inputSet.contains(name) ) { inputSet.add(name); } } // Expand file/directory input so we get a complete set (except ordered) // Should be everything not excluded and not in order list. Set<String> allFilesIncluded = expand(null, inputSet, processed); // Create simple sorted list so we can add ordered items at end. List<String> allFiles = new ArrayList<String>(allFilesIncluded); Collections.sort(allFiles); // Now add the ordered set to the end of the list. // Add in REVERSE ORDER, so that the first element is closest to // the end (and the index). for (int i = orderList.size() - 1; i >= 0; --i) { String s = orderList.get(i); if (allFilesExcluded.contains(s)) { // Disable this warning until 8005688 is fixed // System.err.println("Included order file " + s // + " is also excluded, skipping."); } else if (new File(s).exists()) { allFiles.add(s); } else { System.err.println("Included order file " + s + " missing, skipping."); } } // Print final results. for (String str : allFiles) { out.println(str); } out.flush(); out.close(); }
Example 17
Source File: DebugConsoleImpl.java From linstor-server with GNU General Public License v3.0 | 4 votes |
@Override public void processCommandLine( final PrintStream debugOut, final PrintStream debugErr, final String inputLine, final boolean setupScope ) { String commandLine = inputLine.trim(); if (!inputLine.isEmpty()) { if (inputLine.startsWith("?")) { findCommands( debugOut, debugErr, inputLine.substring(1, inputLine.length()).trim() ); } else if (isHelpCommand(inputLine)) { helpCommand( debugOut, debugErr, inputLine.substring(HELP_COMMAND.length(), inputLine.length()).trim() ); } else { // Parse the debug command line char[] commandChars = commandLine.toCharArray(); String command = parseCommandName(commandChars); try { parseCommandParameters(commandChars); processCommand(debugOut, debugErr, command, setupScope); } catch (ParseException parseExc) { debugErr.println(parseExc.getMessage()); } finally { parameters.clear(); unknownParameters.clear(); } } } }
Example 18
Source File: NameNode.java From hadoop with Apache License 2.0 | 4 votes |
private static void printUsage(PrintStream out) { out.println(USAGE + "\n"); }
Example 19
Source File: IntegrationTestBase.java From jarjar with Apache License 2.0 | 4 votes |
/** * Creates a new jar file by zipping up the given folder. * * @param folder The folder to zip up. * @param manifestEntries Lines to write to the manifest file (optional). * @return The jar file. */ protected File createJar(File folder, String ... manifestEntries) throws IOException { File outputJar = workdir.newFile(); File manifestFile = workdir.newFile(); PrintStream manifestOut = new PrintStream(manifestFile); for (String line : manifestEntries) { manifestOut.println(line); } List<String> jarargs = new LinkedList<String>(); jarargs.add("jar"); jarargs.add("-cfm"); jarargs.add(outputJar.getAbsolutePath()); jarargs.add(manifestFile.getAbsolutePath()); List<String> filesToJar = new LinkedList<String>(); for (String relativePath : new FileTree(folder)) { filesToJar.add(relativePath); } Collections.sort(filesToJar, new Comparator<String>() { @Override public int compare(String a, String b) { return a.compareTo(b); } }); jarargs.addAll(filesToJar); String[] cmd = jarargs.toArray(new String[jarargs.size()]); Process p = Runtime.getRuntime().exec(cmd, null, folder); try { p.waitFor(); } catch (InterruptedException e) { } assertEquals(0, p.exitValue()); assertTrue(outputJar.exists()); return outputJar; }
Example 20
Source File: JDBCDisplayUtil.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
static private void indentedPrintLine( PrintStream out, int indentLevel, StringBuilder text ) { indent( out, indentLevel ); out.println( text ); }