List of usage examples for java.util Formatter toString
public String toString()
From source file:edu.cmu.tetrad.cli.search.FgsCli.java
private static String createArgsInfo() { Formatter fmt = new Formatter(); if (dataFile != null) { fmt.format("data = %s%n", dataFile.getFileName()); }/*from ww w .j a v a2 s.c om*/ if (excludedVariableFile != null) { fmt.format("exclude-variables = %s%n", excludedVariableFile.getFileName()); } if (knowledgeFile != null) { fmt.format("knowledge = %s%n", knowledgeFile.getFileName()); } fmt.format("delimiter = %s%n", Args.getDelimiterName(delimiter)); fmt.format("verbose = %s%n", verbose); fmt.format("thread = %s%n", numOfThreads); fmt.format("penalty-discount = %f%n", penaltyDiscount); fmt.format("ignore-linear-dependence = %s%n", ignoreLinearDependence); fmt.format("depth = %d%n", depth); fmt.format("heuristic-speedup = %s%n", heuristicSpeedup); fmt.format("graphml = %s%n", graphML); fmt.format("skip-unique-var-name = %s%n", skipUniqueVarName); fmt.format("skip-non-zero-variance = %s%n", skipZeroVariance); fmt.format("out = %s%n", dirOut.getFileName().toString()); fmt.format("output-prefix = %s%n", outputPrefix); fmt.format("no-validation-output = %s%n", !validationOutput); return fmt.toString(); }
From source file:edu.cmu.tetrad.cli.search.FgsDiscrete.java
private static String createArgsInfo() { Formatter fmt = new Formatter(); if (dataFile != null) { fmt.format("data = %s%n", dataFile.getFileName()); }//from ww w.j a va2 s . c o m if (excludedVariableFile != null) { fmt.format("exclude-variables = %s%n", excludedVariableFile.getFileName()); } if (knowledgeFile != null) { fmt.format("knowledge = %s%n", knowledgeFile.getFileName()); } fmt.format("delimiter = %s%n", Args.getDelimiterName(delimiter)); fmt.format("verbose = %s%n", verbose); fmt.format("thread = %s%n", numOfThreads); fmt.format("structure-prior = %f%n", structurePrior); fmt.format("sample-prior = %f%n", samplePrior); fmt.format("depth = %d%n", depth); fmt.format("heuristic-speedup = %s%n", heuristicSpeedup); fmt.format("graphml = %s%n", graphML); fmt.format("skip-unique-var-name = %s%n", skipUniqueVarName); fmt.format("skip-category-limit = %s%n", skipCategoryLimit); fmt.format("out = %s%n", dirOut.getFileName().toString()); fmt.format("output-prefix = %s%n", outputPrefix); fmt.format("no-validation-output = %s%n", !validationOutput); return fmt.toString(); }
From source file:edu.ku.brc.specify.plugins.ipadexporter.iPadRepositoryHelper.java
/** * @param hash/*from ww w . j a v a2 s .c o m*/ * @return */ private String byteArray2Hex(byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); } return formatter.toString(); }
From source file:com.diversityarrays.dalclient.DalUtil.java
/** * Computes the MD5 checksum of the bytes in the InputStream. * The input is close()d on exit./* w w w. j av a 2 s .c om*/ * @param input is the InputStream for which to compute the checksum * @return the MD5 checksum as a String of hexadecimal characters */ static public String computeMD5checksum(InputStream input) { DigestInputStream dis = null; Formatter formatter = null; try { MessageDigest md = MessageDigest.getInstance(DIGEST_MD5); dis = new DigestInputStream(input, md); while (-1 != dis.read()) ; byte[] digest = md.digest(); formatter = new Formatter(); for (byte b : digest) { formatter.format("%02x", b); //$NON-NLS-1$ } return formatter.toString(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } finally { if (dis != null) { try { dis.close(); } catch (IOException ignore) { } } if (formatter != null) { formatter.close(); } } }
From source file:org.openecomp.sdc.common.config.EcompErrorLogUtil.java
public static void logEcompError(EcompErrorName ecompErrorName, EcompErrorInfo ecompErrorInfo, String ecompErrorContext, String... ecompDescriptionParams) { if (ecompErrorInfo != null) { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); try {//w w w. j a v a2 s . c o m String description = ecompErrorInfo.getDescription(); String severityStr = ecompErrorInfo.getSeverity(); EcompErrorConfiguration.EcompErrorSeverity severity = EcompErrorSeverity.ERROR; // Since there is no FATAL log level, this is how we distinguish // the FATAL errors if (severityStr.equals(EcompErrorConfiguration.EcompErrorSeverity.FATAL.name())) { description = FATAL_ERROR_PREFIX + description; severity = EcompErrorSeverity.FATAL; } else if (severityStr.equals(EcompErrorConfiguration.EcompErrorSeverity.WARN.name())) { severity = EcompErrorSeverity.WARN; } else if (severityStr.equals(EcompErrorConfiguration.EcompErrorSeverity.INFO.name())) { severity = EcompErrorSeverity.INFO; } MDC.put("alarmSeverity", ecompErrorInfo.getAlarmSeverity()); // else it stays ERROR formatter.format(ECOMP_ERROR_TMPL, ecompErrorInfo.getType(), ecompErrorName.name(), ecompErrorInfo.getCode(), ecompErrorContext, description); switch (severity) { case INFO: log.info(formatter.toString()); break; case WARN: log.warn(formatter.toString()); break; case ERROR: log.error(formatter.toString()); break; case FATAL: // same as ERROR for now, might be additional logic later.. log.error(formatter.toString()); break; default: break; } } finally { formatter.close(); MDC.remove("alarmSeverity"); } } }
From source file:com.itemanalysis.psychometrics.irt.estimation.ItemFitGeneralizedSX2.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format("%5s", "SX2 "); f.format("%8.4f", getValue()); f.format("%2s", ""); f.format("%4d", (int) getDegreesOfFreedom()); f.format("%2s", ""); f.format("%1.4f", getPValue()); return f.toString(); }
From source file:edu.cmu.tetrad.cli.AbstractAlgorithmCli.java
private String creteHeading(AlgorithmType algorithmType) { Formatter fmt = new Formatter(); fmt.format("================================================================================%n"); fmt.format("%s (%s)%n", algorithmType.getTitle(), AppTool.fmtDateNow()); fmt.format("================================================================================%n"); return fmt.toString(); }
From source file:com.itemanalysis.psychometrics.rasch.RatingScaleItem.java
public String printItem() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format("%10s", this.getName().toString()); f.format("%5s", ""); f.format("%8.2f", getDifficulty()); f.format("%5s", ""); for (int i = 0; i < thresholds.length; i++) { f.format("%8.2f", thresholds[i]); f.format("%5s", ""); }//from w ww. j a v a 2 s . c o m return f.toString(); }
From source file:pl.edu.icm.cermine.tools.classification.general.FeatureVectorScalerImpl.java
@Override public void saveRangeFile(String path) throws IOException { BufferedWriter fp_save = null; try {/* www. ja va 2 s . c o m*/ Formatter formatter = new Formatter(new StringBuilder()); fp_save = new BufferedWriter(new FileWriter(path)); double lower = 0.0; double upper = 1.0; formatter.format("x\n"); formatter.format("%.16g %.16g\n", lower, upper); for (int i = 0; i < limits.length; ++i) { formatter.format("%d %.16g %.16g\n", i, limits[i].getMin(), limits[i].getMax()); } fp_save.write(formatter.toString()); } finally { if (fp_save != null) { fp_save.close(); } } }
From source file:umontreal.iro.lecuyer.charts.SSJXYSeriesCollection.java
/** * Returns in a <TT>String</TT> all data contained in the current object. * //ww w .ja v a 2 s.c o m * @return All data contained in the current object as a {@link String}. * */ public String toString() { Formatter formatter = new Formatter(Locale.US); for (int i = 0; i < seriesCollection.getSeriesCount(); i++) { formatter.format(" Series " + i + " : %n"); for (int j = 0; j < seriesCollection.getItemCount(i); j++) formatter.format("%15e,%15e%n", getX(i, j), getY(i, j)); } return formatter.toString(); }