List of usage examples for java.io PrintStream format
public PrintStream format(Locale l, String format, Object... args)
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; PrintStream ps = new PrintStream(System.out); // format a string ps.format(Locale.UK, "This is a %s program", s); // flush to see the string ps.flush();//w ww . j ava 2 s . c o m }
From source file:com.act.lcms.CompareTwoNetCDFAroundMass.java
public static void main(String[] args) throws Exception { if (args.length < 5 || !areNCFiles(Arrays.copyOfRange(args, 3, args.length))) { throw new RuntimeException("Needs: \n" + "(1) mass value, e.g., 132.0772 for debugging, \n" + "(2) how many timepoints to process (-1 for all), \n" + "(3) prefix for .data and rendered .pdf \n" + "(4,5..) 2 or more NetCDF .nc files"); }//from w w w. ja v a 2 s . c om String fmt = "pdf"; Double mz = Double.parseDouble(args[0]); Integer numSpectraToProcess = Integer.parseInt(args[1]); String outPrefix = args[2]; String outImg = outPrefix.equals("-") ? null : outPrefix + "." + fmt; String outData = outPrefix.equals("-") ? null : outPrefix + ".data"; CompareTwoNetCDFAroundMass c = new CompareTwoNetCDFAroundMass(); String[] netCDF_fnames = Arrays.copyOfRange(args, 3, args.length); List<List<Pair<Double, Double>>> spectra = c.getSpectraForMass(mz, netCDF_fnames, numSpectraToProcess); // Write data output to outfile PrintStream out = outData == null ? System.out : new PrintStream(new FileOutputStream(outData)); // print out the spectra to outData for (List<Pair<Double, Double>> spectraInFile : spectra) { for (Pair<Double, Double> xy : spectraInFile) { out.format("%.4f\t%.4f\n", xy.getLeft(), xy.getRight()); out.flush(); } // delimit this dataset from the rest out.print("\n\n"); } // find the ymax across all spectra, so that we can have a uniform y scale Double yrange = 0.0; for (List<Pair<Double, Double>> spectraInFile : spectra) { Double ymax = 0.0; for (Pair<Double, Double> xy : spectraInFile) { Double intensity = xy.getRight(); if (ymax < intensity) ymax = intensity; } if (yrange < ymax) yrange = ymax; } if (outData != null) { // if outData is != null, then we have written to .data file // now render the .data to the corresponding .pdf file // first close the .data out.close(); // render outData to outFILE using gnuplo Gnuplotter plotter = new Gnuplotter(); plotter.plot2D(outData, outImg, netCDF_fnames, "time in seconds", yrange, "intensity", fmt); } }
From source file:com.act.lcms.plotter.WriteAndPlotMS1Results.java
private void writeFeedMS1Values(List<Pair<Double, Double>> concentrationIntensity, OutputStream os) throws IOException { PrintStream out = new PrintStream(os); for (Pair<Double, Double> ci : concentrationIntensity) { out.format("%f\t%f\n", ci.getLeft(), ci.getRight()); }/*from w ww. j a v a 2 s .c om*/ out.flush(); }
From source file:com.act.lcms.plotter.WriteAndPlotMS1Results.java
public void plotScan(List<MS1.YZ> scan, String outPrefix, String fmt) throws IOException { String outPDF = outPrefix + "." + fmt; String outDATA = outPrefix + ".data"; // Write data output to outfile PrintStream out = new PrintStream(new FileOutputStream(outDATA)); // print out the spectra to outDATA for (MS1.YZ yz : scan) { out.format("%.4f\t%.4f\n", yz.getMZ(), yz.getIntensity()); out.flush();/*from w w w . j a v a2 s.c o m*/ } // close the .data out.close(); // render outDATA to outPDF using gnuplot new Gnuplotter().plot2DImpulsesWithLabels(outDATA, outPDF, new String[] { "mz distribution at TIC max" }, null, "mz", null, "intensity", fmt); }
From source file:de.unisb.cs.st.javaslicer.tracer.instrumentation.TracingMethodInstrumenter.java
public static void printStats(final PrintStream out) { out.println();//from w w w.j a v a 2 s . c o m out.println("----------------------------------------------------"); final String format = "%-23s%10d%n"; out.println("Instrumentation statistics:"); out.format(format, "classes", statsClasses); out.format(format, "methods", statsMethods); out.format(format, "instructions", statsInstructions); out.format(format, "labels (no jump target)", statsLabelsStd); out.format(format, "labels (jump target)", statsLabelsJumpTargets); out.format(format, "labels (additional)", statsLabelsAdditional); out.format(format, "array store", statsArrayStore); out.format(format, "array load", statsArrayLoad); out.format(format, "get field", statsGetField); out.format(format, "put field", statsPutField); out.println("----------------------------------------------------"); out.println(); }
From source file:com.analog.lyric.dimple.solvers.core.parameterizedMessages.GammaParameters.java
@Override public void print(PrintStream out, int verbosity) { if (verbosity >= 0) { String fmt;//from ww w. j a v a 2s . c o m switch (verbosity) { case 0: fmt = "Gamma(%g,%g)"; break; default: fmt = "Gamma(alpha=%g, beta=%g)"; break; } out.format(fmt, getAlpha(), getBeta()); } }
From source file:com.zimbra.cs.service.authenticator.CertUtil.java
private void printVersion(PrintStream outStream) { int version = cert.getVersion(); outStream.format("Version: %d (0x%x)\n", version, version); }
From source file:com.zimbra.cs.service.authenticator.CertUtil.java
private void printSerialNumber(PrintStream outStream) { BigInteger serialNumber = cert.getSerialNumber(); outStream.format("Serial Number: %s (0x%x)\n", serialNumber.toString(), serialNumber); }
From source file:com.analog.lyric.dimple.solvers.core.parameterizedMessages.BetaParameters.java
@Override public void print(PrintStream out, int verbosity) { if (verbosity >= 0) { String fmt;//from w w w. ja v a 2 s . c om switch (verbosity) { case 0: fmt = "Beta(%g,%g)"; break; default: fmt = "Beta(alpha=%g, beta=%g)"; break; } out.format(fmt, getAlpha(), getBeta()); } }
From source file:com.zimbra.cs.service.authenticator.CertUtil.java
private void printSigAlg(PrintStream outStream) throws Exception { String sigAlgName = cert.getSigAlgName(); String sigAlgOID = cert.getSigAlgOID(); outStream.format("Signature Algorithm: %s (%s)\n", sigAlgName, sigAlgOID); /*/*from w w w. ja va 2 s . com*/ byte[] sigAlgParams = cert.getSigAlgParams(); AlgorithmParameters algParams = AlgorithmParameters.getInstance(sigAlgName); algParams.init(sigAlgParams); outStream.format("Signature Algorithm Params: %s", algParams.toString()); */ }