List of usage examples for java.io PrintStream print
public void print(Object obj)
From source file:org.apache.hadoop.hdfs.util.LightWeightGSet.java
/** Print detailed information of this object. */ public void printDetails(final PrintStream out) { out.print(this + ", entries = ["); for (int i = 0; i < entries.length; i++) { if (entries[i] != null) { LinkedElement e = entries[i]; out.print("\n " + i + ": " + e); for (e = e.getNext(); e != null; e = e.getNext()) { out.print(" -> " + e); }// w w w .j a v a2s . c o m } } out.println("\n]"); }
From source file:playground.dgrether.analysis.categoryhistogram.CategoryHistogramWriter.java
public void write(CategoryHistogram histo, PrintStream stream) { this.checkIndex(histo); // data about modes, add all first stream.print("time\ttime"); for (String legMode : histo.getCategoryData().keySet()) { stream.print("\t" + departuresName + "_" + legMode + "\t" + arrivalsName + "_" + legMode + "\t" + abortName + "_" + legMode + "\ten-route_" + legMode); }//w w w . j a v a 2 s . c om stream.print("\n"); Map<String, Integer> enRouteMap = new HashMap<String, Integer>(); for (int i = (histo.getFirstIndex() - 2); i <= histo.getLastIndex() + 2; i++) { int seconds = i * histo.getBinSizeSeconds(); stream.print(Time.writeTime(seconds)); stream.print("\t"); stream.print(Integer.toString(seconds)); for (String cat : histo.getCategoryData().keySet()) { int departures = histo.getDepartures(cat, i); int arrivals = histo.getArrivals(cat, i); int stuck = histo.getAbort(cat, i); // log.error("Cat: " + cat + " index " + i + " dep " + departures + " arr " + arrivals + " stuck " + stuck); int enRoute = CategoryHistogramUtils.getNotNullInteger(enRouteMap, cat); int modeEnRoute = enRoute + departures - arrivals - stuck; enRouteMap.put(cat, modeEnRoute); stream.print("\t" + departures + "\t" + arrivals + "\t" + stuck + "\t" + modeEnRoute); } // new line stream.print("\n"); } }
From source file:com.lmco.ddf.commands.catalog.LatestCommand.java
@Override protected Object doExecute() throws Exception { PrintStream console = System.out; String formatString = "%1$-7s %2$-33s %3$-26s %4$-" + MAX_LENGTH + "s%n"; console.printf(formatString, "", "", "", ""); console.print(Ansi.ansi().fg(Ansi.Color.CYAN).toString()); console.printf(formatString, NUMBER, ID, DATE, TITLE); console.print(Ansi.ansi().fg(Ansi.Color.DEFAULT).toString()); CatalogFacade catalogProvider = getCatalog(); Filter filter = getFilterBuilder().attribute(Metacard.MODIFIED).before().date(new Date()); QueryImpl query = new QueryImpl(filter); query.setPageSize(numberOfItems);// ww w. j a va 2 s. c o m query.setSortBy(new SortByImpl(Metacard.MODIFIED, SortOrder.DESCENDING.name())); QueryRequest queryRequest = new QueryRequestImpl(query); SourceResponse response = catalogProvider.query(queryRequest); List<Result> results = response.getResults(); int i = 1; for (Result result : results) { if (result.getMetacard() == null) { continue; } String postedDate = ""; String title = ""; if (result.getMetacard().getModifiedDate() != null) { postedDate = new DateTime(result.getMetacard().getModifiedDate()).toString(DATETIME_FORMATTER); } if (isNotBlank(result.getMetacard().getTitle())) { title = result.getMetacard().getTitle(); } console.printf(formatString, i, result.getMetacard().getId(), postedDate, title.substring(0, Math.min(title.length(), MAX_LENGTH))); i++; } return null; }
From source file:avantssar.aslanpp.testing.TranslationInstance.java
public void report(PrintStream out, int index, List<String> backendNames, boolean odd) { out.print("<tr style='background-color: "); out.print(TranslationReport.BG(odd)); out.println(";'>"); out.println("<td style='text-align: right;'>" + index + "</td>"); out.print("<td"); boolean different = false; boolean differentDet = false; if (aslanPPcheck1 != null || aslanPPcheck2 != null) { try {//from w w w. j a v a 2 s . c om if (aslanPPcheck1 != null && aslanPPcheck2 != null) { different = !FileUtils.contentEquals(aslanPPcheck1, aslanPPcheck2); } else { different = true; } if (aslanPPcheck1det != null && aslanPPcheck2det != null) { differentDet = !FileUtils.contentEquals(aslanPPcheck1det, aslanPPcheck2det); } else { differentDet = aslanPPcheck1det != null || aslanPPcheck2det != null; } out.print(" style='background-color: "); if (different || differentDet) { out.print(TranslationReport.RED(odd)); } else { out.print(TranslationReport.GREEN(odd)); } out.print(";'"); } catch (IOException e) { Debug.logger.error("Failed to compare files '" + aslanPPcheck1.getAbsolutePath() + "' and '" + aslanPPcheck2.getAbsolutePath() + "'.", e); } } out.print(">"); HTMLHelper.fileOrDash(out, outputDir, aslanPPfile, null); // if (different) { // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck1, "pp1"); // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck2, "pp2"); // } // if (differentDet) { // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck1det, "pp1d"); // out.print(" "); // HTMLHelper.fileOrDash(out, aslanPPcheck2det, "pp2d"); // } out.println("</td>"); out.print("<td style='background-color: "); if (errors > 0) { out.print(TranslationReport.RED(odd)); } else { out.print(TranslationReport.GREEN(odd)); } out.print(";'>"); HTMLHelper.fileOrDash(out, outputDir, errorsFile, errors > 0 ? Integer.toString(errors) : "-"); out.println("</td>"); out.print("<td style='background-color: "); if (warnings > 0) { out.print(TranslationReport.RED(odd)); } else { out.print(TranslationReport.GREEN(odd)); } out.print(";'>"); HTMLHelper.fileOrDash(out, outputDir, warningsFile, warnings > 0 ? Integer.toString(warnings) : "-"); out.println("</td>"); filesCompared(out, aslanFile, expectedASLanFile, "expected", odd); out.println("<td>" + expectedVerdict.toString() + "</td>"); for (String s : backendNames) { BackendRun br = verdicts.get(s); if (br != null) { br.report(out, odd, expectedVerdict); } else { out.print("<td>-</td>"); } } out.println("</tr>"); }
From source file:org.commonjava.maven.galley.io.checksum.AbstractChecksumGenerator.java
public final void write() throws IOException { if (!writeChecksumFile) { return;// w w w .java2 s.co m } logger.info("Writing {} file: {}", checksumExtension, checksumTransfer); PrintStream out = null; OutputStream stream = null; try { stream = checksumTransfer.openOutputStream(TransferOperation.GENERATE); out = new PrintStream(stream); out.print(getDigestHex()); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(stream); } }
From source file:ie.aib.nbp.zosconnect.ZosRestServicePerformanceRunner.java
public long executeServices(String URI, String username, String password, String payload, PrintStream out, boolean attachResponse, boolean formatResponse) { long elapsedTime = 0L; //SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); //out.print("Start DateTime: "+sdf.format(new Date())+" response: "); out.print("Call succeeded, response: "); if (formatResponse) out.println();/*from w w w.j ava 2 s . c o m*/ long startTime = System.currentTimeMillis(); if (this.connector.isReadyToGo()) { String response = this.connector.makePostRequest(URI, username, password, payload); try { JSONObject result = new JSONObject(response); if (attachResponse) { String output = formatResponse ? result.toString(4) : result.toString(); out.println(output); } //calculate execution time elapsedTime = System.currentTimeMillis() - startTime; //out.print("End DateTime: "+sdf.format(new Date())+" "); out.println("service call completed in " + elapsedTime + " miliseconds."); } catch (Exception ex) { out.println("execution failed or hit the timeout !!!"); } } return elapsedTime; }
From source file:fi.jumi.core.stdout.OutputCapturerTest.java
@Test public void starting_a_new_capture_does_not_require_installing_a_new_PrintStream_to_SystemOut() { OutputListenerSpy listener = new OutputListenerSpy(); PrintStream out = capturer.out(); capturer.captureTo(listener);// w w w . ja v a2 s . c o m out.print("foo"); assertThat(listener.out).containsExactly("foo"); }
From source file:jenkins.plugins.logstash.persistence.ElasticSearchDao.java
private String getErrorMessage(CloseableHttpResponse response) { ByteArrayOutputStream byteStream = null; PrintStream stream = null; try {//w w w. j ava2 s. c o m byteStream = new ByteArrayOutputStream(); stream = new PrintStream(byteStream); try { stream.print("HTTP error code: "); stream.println(response.getStatusLine().getStatusCode()); stream.print("URI: "); stream.println(uri.toString()); stream.println("RESPONSE: " + response.toString()); response.getEntity().writeTo(stream); } catch (IOException e) { stream.println(ExceptionUtils.getStackTrace(e)); } stream.flush(); return byteStream.toString(); } finally { if (stream != null) { stream.close(); } } }
From source file:com.alvermont.javascript.tools.shell.ShellMain.java
/** * Evaluate JavaScript source./*from w ww . jav a 2 s.c o m*/ * * @param cx the current context * @param filename the name of the file to compile, or null * for interactive mode. */ public static void processSource(Context cx, String filename) { if (filename == null || filename.equals("-")) { final PrintStream ps = GLOBAL.getErr(); if (filename == null) { // print implementation version ps.println(cx.getImplementationVersion()); } // Use the interpreter for interactive input cx.setOptimizationLevel(-1); final BufferedReader in = new BufferedReader(new InputStreamReader(GLOBAL.getIn())); int lineno = 1; boolean hitEOF = false; while (!hitEOF) { final int startline = lineno; if (filename == null) { ps.print("js> "); } ps.flush(); String source = ""; // Collect lines of source to compile. while (true) { String newline; try { newline = in.readLine(); } catch (IOException ioe) { ps.println(ioe.toString()); break; } if (newline == null) { hitEOF = true; break; } source = source + newline + "\n"; ++lineno; if (cx.stringIsCompilableUnit(source)) { break; } } final Script script = loadScriptFromSource(cx, source, "<stdin>", lineno, null); if (script != null) { final Object result = evaluateScript(script, cx, GLOBAL); if (result != Context.getUndefinedValue()) { try { ps.println(Context.toString(result)); } catch (RhinoException rex) { ToolErrorReporter.reportException(cx.getErrorReporter(), rex); } } final NativeArray h = GLOBAL.getHistory(); h.put((int) h.getLength(), h, source); } } ps.println(); } else { processFile(cx, GLOBAL, filename); } System.gc(); }
From source file:cc.arduino.packages.ssh.SSH.java
private void consumeStream(byte[] buffer, InputStream in, PrintStream out) throws IOException { while (in.available() > 0) { int length = in.read(buffer, 0, buffer.length); if (length < 0) { break; }// w ww . ja va 2 s. co m if (out != null) { out.print(new String(buffer, 0, length)); } } }