List of usage examples for java.io PrintStream printf
public PrintStream printf(String format, Object... args)
From source file:nu.mine.kino.jenkins.plugins.projectmanagement.utils.PMUtils.java
/** * nv?WFNg?Ant@CrhfBNg??ArhT?A?B// www . j a v a 2s.c o m * * @param project * @param fileName * @param out * @param err * @return */ public static String findSeriesFile(AbstractProject<?, ?> project, String fileName, PrintStream out, PrintStream err) { AbstractBuild<?, ?> build = PMUtils.findBuild(project, fileName); if (build == null) { out.printf("EVMn?t@C(%s)v?WFNg???At@C?VK???B\n", fileName); return null; } else { out.printf("EVMn?t@C(%s) rh #%s ??B\n", fileName, build.getNumber()); } try { return ReadUtils.readFile(new File(build.getRootDir(), fileName)); } catch (IOException e) { err.println("EVMn?t@CT?G?[??At@C?VK???B"); } return null; }
From source file:com.zimbra.cs.redolog.util.RedoLogVerify.java
private static void hexdump(PrintStream out, byte[] data, int offset, int length, long offsetOffsetBy, long badBytePos) { int end = Math.min(offset + length, data.length); int bytesPerLine = 16; while (offset < end) { int bytes = Math.min(bytesPerLine, end - offset); // bytes for this line long offsetLineStart = offset + offsetOffsetBy; long offsetLineEnd = offsetLineStart + bytes; out.printf("%08x: ", offsetLineStart); for (int i = 0; i < bytesPerLine; i++) { if (i < bytes) out.printf("%02x", ((int) data[offset + i]) & 0x000000ff); else/* w w w .j a v a2 s . c om*/ out.print(" "); out.print(" "); if (i == 7) out.print(" "); } out.print(" "); for (int i = 0; i < bytesPerLine; i++) { if (i < bytes) { int ch = ((int) data[offset + i]) & 0x000000ff; if (ch >= 33 && ch <= 126) // printable ASCII range out.printf("%c", (char) ch); else out.print("."); } else { out.print(" "); } } if (offsetLineStart <= badBytePos && badBytePos < offsetLineEnd) out.print(" **"); out.println(); offset += bytes; } }
From source file:Armadillo.Analytics.Base.FastMathCalc.java
/** * Print an array.//from ww w. jav a2 s . c o m * @param out text output stream where output should be printed * @param name array name * @param expectedLen expected length of the array * @param array array data */ static void printarray(PrintStream out, String name, int expectedLen, double[] array) { out.println(name + "="); checkLen(expectedLen, array.length); out.println(TABLE_START_DECL); for (double d : array) { out.printf(" %s%n", format(d)); // one entry per line } out.println(TABLE_END_DECL); }
From source file:Armadillo.Analytics.Base.FastMathCalc.java
/** * Print an array.//from w w w . j a va 2 s . com * @param out text output stream where output should be printed * @param name array name * @param expectedLen expected length of the array * @param array2d array data */ static void printarray(PrintStream out, String name, int expectedLen, double[][] array2d) { out.println(name); checkLen(expectedLen, array2d.length); out.println(TABLE_START_DECL + " "); int i = 0; for (double[] array : array2d) { // "double array[]" causes PMD parsing error out.print(" {"); for (double d : array) { // assume inner array has very few entries out.printf("%-25.25s", format(d)); // multiple entries per line } out.println("}, // " + i++); } out.println(TABLE_END_DECL); }
From source file:org.rhwlab.BHCnotused.StdGaussianWishartGaussian.java
@Override public void print(PrintStream stream) { stream.printf("Size=%d\n", data.size()); boolean first = true; for (RealVector v : data) { if (!first) { stream.print(","); }//from w w w.j ava 2 s . c om printVector(stream, v); first = false; } stream.println(); stream.printf("Likelihood: %s\n", Double.toString(likelihood)); }
From source file:org.kiji.mapreduce.tools.KijiJobHistory.java
/** * Prints a job details./*w w w .j av a2s . c o m*/ * @param data A row data containing a serialization of the job details. * @throws IOException If there is an error retrieving the counters. */ private void printRow(KijiRowData data) throws IOException { final PrintStream ps = getPrintStream(); ps.printf("Job:\t\t%s%n", data.getMostRecentValue("info", "jobId")); ps.printf("Name:\t\t%s%n", data.getMostRecentValue("info", "jobName")); ps.printf("Started:\t%s%n", new Date((Long) data.getMostRecentValue("info", "startTime"))); ps.printf("Ended:\t\t%s%n", new Date((Long) data.getMostRecentValue("info", "endTime"))); ps.printf("End Status:\t\t%s%n", data.getMostRecentValue("info", "jobEndStatus")); if (mVerbose) { printCounters(data); printConfiguration(data); } }
From source file:com.sangupta.jerry.util.FileUtils.java
/** * Dump a given file into HEX starting at given offset and reading given number of rows where * a row consists of 16-bytes./*w w w .j a v a 2 s . c o m*/ * * @param out * @param file * @param offset * @param maxRows * @throws IOException */ public static void hexDump(PrintStream out, File file, long offset, int maxRows) throws IOException { InputStream is = null; BufferedInputStream bis = null; try { is = new FileInputStream(file); bis = new BufferedInputStream(is); bis.skip(offset); int row = 0; if (maxRows == 0) { maxRows = Integer.MAX_VALUE; } StringBuilder builder1 = new StringBuilder(100); StringBuilder builder2 = new StringBuilder(100); while (bis.available() > 0) { out.printf("%04X ", row * 16); for (int j = 0; j < 16; j++) { if (bis.available() > 0) { int value = (int) bis.read(); builder1.append(String.format("%02X ", value)); if (!Character.isISOControl(value)) { builder2.append((char) value); } else { builder2.append("."); } } else { for (; j < 16; j++) { builder1.append(" "); } } } out.print(builder1); out.println(builder2); row++; if (row > maxRows) { break; } builder1.setLength(0); builder2.setLength(0); } } finally { IOUtils.closeQuietly(bis); IOUtils.closeQuietly(is); } }
From source file:org.rhwlab.BHCnotused.Cluster.java
public void printCluster(PrintStream stream) { data.print(stream);/* www . ja va 2s . co m*/ stream.printf("dpm=%s\n", this.dpm.toString()); stream.printf("pi=%s\n", this.pi.toString()); }
From source file:pt.lsts.neptus.util.ByteUtil.java
/** * Dumps the byte array as hex string to the {@link PrintStream}, with a title. * //from ww w .j a v a2 s . c om * @param title * @param buffer * @param pStream */ public static void dumpAsHex(String title, byte[] buffer, PrintStream pStream) { String txt = ""; if (!"".equalsIgnoreCase(title) && title != null) { txt = title + " "; } if (buffer == null) txt += "NULL"; else txt += "[size: " + buffer.length + " bytes]"; pStream.println("---------------------------------------------------------- ----------------"); pStream.println(txt); pStream.println("---------------------------------------------------------- ----------------"); if (buffer == null) return; char[] chars = Hex.encodeHex(buffer); int charCount = 0; StringBuffer lineChars = new StringBuffer(16); int byteCount = 0, halfByteCount = 0, lineCount = 0; String regex = "[\\s\\e\\a\\x1f\0]"; String replacement = " "; for (char ch : chars) { if (byteCount == 0 && halfByteCount == 0) { pStream.printf("%8X: ", lineCount * 16); } pStream.print(ch); if (halfByteCount == 1) { pStream.print(' '); lineChars.append(new String(new byte[] { buffer[charCount] }).charAt(0)); //lineChars.append(new String(".").charAt(0)); charCount++; } if (halfByteCount == 1) byteCount = ++byteCount % 16; if (byteCount == 8 && halfByteCount == 1) pStream.print(' '); if (byteCount == 0 && halfByteCount == 1) { if (charCount % 16 != 0) { //This here will probably never be called (check) for (int i = 0; i < 16 - charCount % 16; i++) pStream.print(" "); if (charCount % 16 < 8) pStream.print(' '); } pStream.print(" " + lineChars.toString().replaceAll(regex, replacement)); lineChars = new StringBuffer(16); pStream.print('\n'); lineCount++; } halfByteCount = ++halfByteCount % 2; } if (byteCount != 0) { if (charCount % 16 != 0) { for (int i = 0; i < 16 - charCount % 16; i++) pStream.print(" "); if (charCount % 16 < 8) pStream.print(' '); } pStream.print(" " + lineChars.toString().replaceAll(regex, replacement)); lineChars = new StringBuffer(16); pStream.print('\n'); } pStream.println("---------------------------------------------------------- ----------------"); }
From source file:org.rhwlab.BHCnotused.GaussianGIWPrior.java
@Override public void print(PrintStream stream) { stream.printf("Size=%d\n", data.size()); stream.printf("%s\n", asString()); stream.printf("Likelihood: %s\n", this.likelihood.toString()); }