List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:com.hpe.application.automation.tools.run.ServiceInfo.java
protected void logConfig(PrintStream logger, String prefix) { SvServiceSelectionModel ss = model.getServiceSelection(); switch (ss.getSelectionType()) { case SERVICE: logger.println(prefix + "Service name or id: " + ss.getService()); break;//from ww w . j a v a 2s. co m case PROJECT: logger.println(prefix + "Project path: " + ss.getProjectPath()); logger.println(prefix + "Project password: " + ((StringUtils.isNotBlank(ss.getProjectPassword())) ? "*****" : null)); break; case ALL_DEPLOYED: logger.println(prefix + "All deployed services"); break; case DEPLOY: logger.println(prefix + "Project path: " + ss.getProjectPath()); logger.println(prefix + "Project password: " + ((StringUtils.isNotBlank(ss.getProjectPassword())) ? "*****" : null)); logger.println(prefix + "Service name or id: " + ss.getService()); break; } logger.println(prefix + "Force: " + model.isForce()); }
From source file:fr.univnantes.lina.UIMAProfiler.java
@Override public void display(PrintStream stream) { if (isEmpty()) return;/* w w w. j a va 2s . c o m*/ stream.println( "###########################################################################################"); stream.println( "#################################### " + this.name + " ####################################"); stream.println( "###########################################################################################"); String formatString = "%30s %10sms\n"; if (!tasks.isEmpty()) { stream.println("--------------- Tasks --------------"); for (String taskName : tasks.keySet()) { long t = 0; for (ProfilingTask task : tasks.get(taskName)) t += task.getTotal(); stream.format(formatString, taskName, t); } stream.format(formatString, "TOTAL", getTotal()); } if (!counters.isEmpty()) { stream.println("--------------- Hits ------------------"); formatString = "%30s %10s\n"; long total = 0; Comparator<String> comp = new Comparator<String>() { @Override public int compare(String o1, String o2) { return Integer.compare(counters.get(o2).intValue(), counters.get(o1).intValue()); } }; List<String> sortedkeys = new LinkedList<String>(); sortedkeys.addAll(counters.keySet()); Collections.sort(sortedkeys, comp); for (String hitName : sortedkeys) { int h = counters.get(hitName).intValue(); total += h; stream.format(formatString, hitName, h); } stream.format(formatString, "TOTAL", total); if (latexFormat) { stream.println("--------------- Hits (Latex) ----------"); total = 0; sortedkeys = new LinkedList<String>(); sortedkeys.addAll(counters.keySet()); Collections.sort(sortedkeys, comp); for (String hitName : sortedkeys) { int h = counters.get(hitName).intValue(); total += h; stream.println(hitName + " & " + counters.get(hitName).intValue() + " \\\\"); } stream.println("TOTAL & " + total + " \\\\"); } } if (!examples.isEmpty()) { stream.println("-------------- Examples ---------------"); List<String> keySet = Lists.newArrayList(examples.keySet()); Collections.shuffle(keySet); for (String hitName : keySet) { int i = 0; stream.println("* " + hitName); for (Object o : examples.get(hitName)) { i++; if (i > exampleLimit) break; String str = o == null ? "null" : o.toString().replaceAll("\n", " ").replaceAll("\r", " ").toLowerCase(); stream.println("\t" + str); } } } if (!pointStatus.isEmpty()) { stream.println("-------------- Point status -----------"); for (String point : pointStatus.keySet()) { stream.println(point + ": " + pointStatus.get(point)); } } stream.flush(); }
From source file:ca.nines.ise.cmd.Abbrs.java
/** * {@inheritDoc}/*w w w . ja v a 2 s . co m*/ */ @Override public void execute(CommandLine cmd) throws Exception { File[] files; Locale.setDefault(Locale.ENGLISH); PrintStream out = new PrintStream(System.out, true, "UTF-8"); if (cmd.hasOption("l")) { out = new PrintStream(new FileOutputStream(cmd.getOptionValue("l")), true, "UTF-8"); } files = getFilePaths(cmd); Formatter formatter = new Formatter(out); if (files != null) { out.println("Found " + files.length + " files to check."); for (File in : files) { DOM dom = new DOMBuilder(in).build(); for (Node n : dom) { if (n.type() == NodeType.ABBR) { formatter.format("%s:%d:%d%n", n.getSource(), n.getLine(), n.getColumn()); formatter.format(" near TLN %s%n", n.getTLN()); formatter.format(" %s%n", n.getText().substring(0, Math.min(64, n.getText().length()))); formatter.format(" %s%n", dom.getLine(n.getLine() - 1)); formatter.format("%n"); } } } } }
From source file:com.github.segator.jenkins.scaleway.ScalewayComputerLauncher.java
private Connection getServerConnection(String host, int port, PrintStream logger) throws IOException { logger.println("Connecting to " + host + " on port " + port + ". "); Connection conn = new Connection(host, port); try {/*from www. ja v a 2s.co m*/ conn.connect(null, 10 * 1000, 10 * 1000); } catch (SocketTimeoutException e) { return null; } logger.println("Connected via SSH."); return conn; }
From source file:hudson.gridmaven.gridlayer.HadoopInstance.java
/** * List files stored in HDFS for debugging purposes. *//* ww w. j a va 2 s. c om*/ public void listFiles(String path, PrintStream print) { Path p = new Path(path); try { FileStatus[] status = fs.listStatus(p); if (status.length < 1) { print.println("Zero files stored in HDFS"); } for (int i = 0; i < status.length; i++) { print.println("Reading file: " + status[i].getPath()); } } catch (IOException ex) { Logger.getLogger(HadoopInstance.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.dubture.jenkins.digitalocean.ComputerLauncher.java
/** * Connects to the given {@link Computer} via SSH and installs Java/Jenkins agent if necessary. *///w ww .j a v a2 s. c o m @Override public void launch(SlaveComputer _computer, TaskListener listener) { Computer computer = (Computer) _computer; PrintStream logger = listener.getLogger(); Date startDate = new Date(); logger.println("Start time: " + getUtcDate(startDate)); final Connection conn; Connection cleanupConn = null; boolean successful = false; try { conn = connectToSsh(computer, logger); cleanupConn = conn; logger.println("Authenticating as " + computer.getRemoteAdmin()); if (!conn.authenticateWithPublicKey(computer.getRemoteAdmin(), computer.getNode().getPrivateKey().toCharArray(), "")) { logger.println("Authentication failed"); throw new Exception("Authentication failed"); } final SCPClient scp = conn.createSCPClient(); if (!runInitScript(computer, logger, conn, scp)) { return; } if (!installJava(logger, conn)) { return; } logger.println("Copying slave.jar"); scp.put(Jenkins.getInstance().getJnlpJars("slave.jar").readFully(), "slave.jar", "/tmp"); String jvmOpts = Util.fixNull(computer.getNode().getJvmOpts()); String launchString = "java " + jvmOpts + " -jar /tmp/slave.jar"; logger.println("Launching slave agent: " + launchString); final Session sess = conn.openSession(); sess.execCommand(launchString); computer.setChannel(sess.getStdout(), sess.getStdin(), logger, new Channel.Listener() { @Override public void onClosed(Channel channel, IOException cause) { sess.close(); conn.close(); } }); successful = true; } catch (Exception e) { try { Jenkins.getInstance().removeNode(computer.getNode()); } catch (Exception ee) { ee.printStackTrace(logger); } e.printStackTrace(logger); } finally { Date endDate = new Date(); logger.println("Done setting up at: " + getUtcDate(endDate)); logger.println("Done in " + TimeUnit2.MILLISECONDS.toSeconds(endDate.getTime() - startDate.getTime()) + " seconds"); if (cleanupConn != null && !successful) { cleanupConn.close(); } } }
From source file:edu.emory.mathcs.nlp.zzz.CSVSentiment.java
public void toTXT(String inputFile) throws Exception { CSVParser parser = new CSVParser(IOUtils.createBufferedReader(inputFile), CSVFormat.DEFAULT); PrintStream fout = IOUtils.createBufferedPrintStream(inputFile + ".txt"); List<CSVRecord> records = parser.getRecords(); CSVRecord record;/*from www. java 2 s .c o m*/ System.out.println(inputFile); for (int i = 0; i < records.size(); i++) { if (i == 0) continue; record = records.get(i); fout.println(record.get(6)); } fout.close(); parser.close(); }
From source file:edu.umn.cs.spatialHadoop.operations.KNN.java
private static <S extends Shape> long knnLocal(Path inFile, Path outPath, OperationsParams params) throws IOException, InterruptedException { int iterations = 0; FileSystem fs = inFile.getFileSystem(params); Point queryPoint = (Point) OperationsParams.getShape(params, "point"); int k = params.getInt("k", 1); // Top-k objects are retained in this object PriorityQueue<ShapeWithDistance<S>> knn = new KNNObjects<ShapeWithDistance<S>>(k); SpatialInputFormat3<Rectangle, Shape> inputFormat = new SpatialInputFormat3<Rectangle, Shape>(); final GlobalIndex<Partition> gIndex = SpatialSite.getGlobalIndex(fs, inFile); double kthDistance = Double.MAX_VALUE; if (gIndex != null) { // There is a global index, use it PriorityQueue<ShapeWithDistance<Partition>> partitionsToProcess = new PriorityQueue<KNN.ShapeWithDistance<Partition>>() { {//from w w w . j av a2 s .c om initialize(gIndex.size()); } @Override protected boolean lessThan(Object a, Object b) { return ((ShapeWithDistance<Partition>) a).distance < ((ShapeWithDistance<Partition>) b).distance; } }; for (Partition p : gIndex) { double distance = p.getMinDistanceTo(queryPoint.x, queryPoint.y); partitionsToProcess.insert(new ShapeWithDistance<Partition>(p.clone(), distance)); } while (partitionsToProcess.size() > 0 && partitionsToProcess.top().distance <= kthDistance) { ShapeWithDistance<Partition> partitionToProcess = partitionsToProcess.pop(); // Process this partition Path partitionPath = new Path(inFile, partitionToProcess.shape.filename); long length = fs.getFileStatus(partitionPath).getLen(); FileSplit fsplit = new FileSplit(partitionPath, 0, length, new String[0]); RecordReader<Rectangle, Iterable<Shape>> reader = inputFormat.createRecordReader(fsplit, null); if (reader instanceof SpatialRecordReader3) { ((SpatialRecordReader3) reader).initialize(fsplit, params); } else if (reader instanceof RTreeRecordReader3) { ((RTreeRecordReader3) reader).initialize(fsplit, params); } else if (reader instanceof HDFRecordReader) { ((HDFRecordReader) reader).initialize(fsplit, params); } else { throw new RuntimeException("Unknown record reader"); } iterations++; while (reader.nextKeyValue()) { Iterable<Shape> shapes = reader.getCurrentValue(); for (Shape shape : shapes) { double distance = shape.distanceTo(queryPoint.x, queryPoint.y); if (distance <= kthDistance) knn.insert(new ShapeWithDistance<S>((S) shape.clone(), distance)); } } reader.close(); if (knn.size() >= k) kthDistance = knn.top().distance; } } else { // No global index, have to scan the whole file Job job = new Job(params); SpatialInputFormat3.addInputPath(job, inFile); List<InputSplit> splits = inputFormat.getSplits(job); for (InputSplit split : splits) { RecordReader<Rectangle, Iterable<Shape>> reader = inputFormat.createRecordReader(split, null); if (reader instanceof SpatialRecordReader3) { ((SpatialRecordReader3) reader).initialize(split, params); } else if (reader instanceof RTreeRecordReader3) { ((RTreeRecordReader3) reader).initialize(split, params); } else if (reader instanceof HDFRecordReader) { ((HDFRecordReader) reader).initialize(split, params); } else { throw new RuntimeException("Unknown record reader"); } iterations++; while (reader.nextKeyValue()) { Iterable<Shape> shapes = reader.getCurrentValue(); for (Shape shape : shapes) { double distance = shape.distanceTo(queryPoint.x, queryPoint.y); knn.insert(new ShapeWithDistance<S>((S) shape.clone(), distance)); } } reader.close(); } if (knn.size() >= k) kthDistance = knn.top().distance; } long resultCount = knn.size(); if (outPath != null && params.getBoolean("output", true)) { FileSystem outFS = outPath.getFileSystem(params); PrintStream ps = new PrintStream(outFS.create(outPath)); Vector<ShapeWithDistance<S>> resultsOrdered = new Vector<ShapeWithDistance<S>>((int) resultCount); resultsOrdered.setSize((int) resultCount); while (knn.size() > 0) { ShapeWithDistance<S> nextAnswer = knn.pop(); resultsOrdered.set(knn.size(), nextAnswer); } Text text = new Text(); for (ShapeWithDistance<S> answer : resultsOrdered) { text.clear(); TextSerializerHelper.serializeDouble(answer.distance, text, ','); answer.shape.toText(text); ps.println(text); } ps.close(); } TotalIterations.addAndGet(iterations); return resultCount; }
From source file:br.com.ingenieux.mojo.beanstalk.env.DumpEnvironmentSettings.java
protected Object executeInternal() throws Exception { DescribeConfigurationOptionsResult configOptions = getService() .describeConfigurationOptions(new DescribeConfigurationOptionsRequest() .withApplicationName(applicationName).withEnvironmentName(curEnv.getEnvironmentName())); for (ConfigurationOptionDescription o : configOptions.getOptions()) { String key = String.format("beanstalk.env.%s.%s", o.getNamespace().replace(":", "."), o.getName()); for (Map.Entry<String, ConfigurationOptionSetting> entry : COMMON_PARAMETERS.entrySet()) { ConfigurationOptionSetting cos = entry.getValue(); if (cos.getNamespace().equals(o.getNamespace()) && cos.getOptionName().equals(o.getName())) { key = entry.getKey();//from w w w . j a va 2 s . co m break; } } defaultSettings.put(key, o); } DescribeConfigurationSettingsResult configurationSettings = getService() .describeConfigurationSettings(new DescribeConfigurationSettingsRequest() .withApplicationName(applicationName).withEnvironmentName(curEnv.getEnvironmentName())); Properties newProperties = new Properties(); if (configurationSettings.getConfigurationSettings().isEmpty()) { throw new IllegalStateException("No Configuration Settings received"); } ConfigurationSettingsDescription configSettings = configurationSettings.getConfigurationSettings().get(0); Map<String, ConfigurationOptionSetting> keyMap = new LinkedHashMap<String, ConfigurationOptionSetting>(); for (ConfigurationOptionSetting d : configSettings.getOptionSettings()) { String key = String.format("beanstalk.env.%s.%s", d.getNamespace().replaceAll(":", "."), d.getOptionName()); String defaultValue = ""; String outputKey = key; keyMap.put(key, d); for (Map.Entry<String, ConfigurationOptionSetting> cosEntry : COMMON_PARAMETERS.entrySet()) { ConfigurationOptionSetting v = cosEntry.getValue(); boolean match = v.getNamespace().equals(d.getNamespace()) && v.getOptionName().equals(d.getOptionName()); if (match) { outputKey = cosEntry.getKey(); break; } } if (defaultSettings.containsKey(outputKey)) { defaultValue = StringUtils.defaultString(defaultSettings.get(outputKey).getDefaultValue()); } String value = d.getValue(); if (null == value || StringUtils.isBlank("" + value)) { continue; } if (!defaultValue.equals(value)) { if (!value.contains(curEnv.getEnvironmentId())) { getLog().info("Adding property " + key); if (changedOnly) { String curValue = project.getProperties().getProperty(outputKey); if (!value.equals(curValue)) { newProperties.put(outputKey, value); } } else { newProperties.put(outputKey, value); } } else { getLog().info("Ignoring property " + outputKey + "(value=" + value + ") due to containing references to the environment id"); } } else { getLog().debug("Ignoring property " + key + " (defaulted)"); } } if ("properties".equals(this.outputFileFormat)) { String comment = "elastic beanstalk environment properties for " + curEnv.getEnvironmentName(); if (null != outputFile) { newProperties.store(new FileOutputStream(outputFile), comment); } else { newProperties.store(System.out, comment); } } else if ("yaml".equals(this.outputFileFormat)) { PrintStream printStream = System.out; if (null != outputFile) { printStream = new PrintStream(outputFile); } printStream.println("option_settings:"); for (Map.Entry<Object, Object> e : newProperties.entrySet()) { ConfigurationOptionSetting c = keyMap.get("" + e.getKey()); String value = "" + e.getValue(); printStream.println(" - namespace: " + c.getNamespace()); printStream.println(" option_name: " + c.getOptionName()); printStream.println(" value: " + value); } printStream.close(); } return null; }
From source file:com.recomdata.export.HeatMapTable.java
public void writeToFile(String delimiter, PrintStream ps, Boolean addMeans) { // outputs a data table, suitable for export to genepattern ps.println("#1.2"); if (addMeans) { ps.println(rows.size() + delimiter + columns.size()); } else {/*from ww w.j av a 2 s .c o m*/ ps.println(rows.size() + delimiter + (columns.size() - 1)); } ps.print("NAME" + delimiter + "Description"); // to assure that columns are returned in the right order, // build a list of subject ids, then sort the list ArrayList<String> ids = new ArrayList<String>(); for (String id : ids1.values()) { ids.add(id); } for (String id : ids2.values()) { ids.add(id); } // ids should be numerically sorted already... java.util.Collections.sort(ids, new subjectComparator()); for (String id : ids) { ps.print(delimiter + id); } if (addMeans) { ps.print(delimiter + "Mean"); } ps.print("\n"); HeatMapRow row; Double sumOfValues = 0.0; Double countOfValues = 0.0; for (String gene : rows.keySet()) { ps.print(gene + delimiter + descriptions.get(gene)); row = rows.get(gene); for (String id : ids) { String value = row.get(id); if (value == "null" || value == "") { // causes problems in genepattern value = ""; } else if (addMeans) { // System.out.println(gene + ", " + id + ": " + value); sumOfValues = sumOfValues + Double.valueOf(value); countOfValues = countOfValues + 1; } ps.print(delimiter + value); } if (addMeans) { Double mean = 0.0; if (countOfValues > 0) { mean = sumOfValues / countOfValues; } ps.print(delimiter + mean); } ps.print("\n"); } }