List of usage examples for java.util Formatter toString
public String toString()
From source file:com.itemanalysis.psychometrics.mixture.MvNormalComponentDistribution.java
public String printMixingProportion() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format("%6.4f", pi); f.format("%n"); return f.toString(); }
From source file:org.smurn.fitzer.FitsFormatException.java
/** * Gets the message describing the error in the given locale. * @param locale Locale in which to return the message. * @return Message in the given locale./* w w w . ja va2s.co m*/ */ @Override public String getLocalizedMessage(Locale locale) { ResourceBundle messages = ResourceBundle.getBundle("org.smurn.fitzer.messages", locale); Formatter formatter = new Formatter(locale); formatter.format(messages.getString("FitsFormatException"), offset); return formatter.toString() + super.getLocalizedMessage(locale); }
From source file:org.smurn.fitzer.FitsException.java
/** * Gets the message describing the error in the given locale. * @param locale Locale in which to return the message. * @return Message in the given locale.//from w w w. ja v a2s . com */ public String getLocalizedMessage(Locale locale) { ResourceBundle messages = ResourceBundle.getBundle("org.smurn.fitzer.messages", locale); Formatter formatter = new Formatter(locale); formatter.format(messages.getString(messageKey), messageParameters); return formatter.toString(); }
From source file:com.itemanalysis.psychometrics.reliability.AbstractScoreReliability.java
public String confidenceIntervalToString(double[] confidenceInterval) { StringBuilder builder = new StringBuilder(); Formatter f = new Formatter(builder); f.format("(%6.4f, ", confidenceInterval[0]); f.format("%6.4f)", confidenceInterval[1]); return f.toString(); }
From source file:ar.com.zauber.garfio.services.impl.HourMinuteTimeConverter.java
/** @see TimeConverter#toHours(String)*/ public final String toHours(final String time) { Validate.isTrue(supportsTime(time)); Matcher m = timePattern.matcher(time); m.matches();//w ww. j a v a2 s .c om StringBuilder builder = new StringBuilder(); if (m.group(1) != null) { builder.append(m.group(1)); } if (m.group(3) != null) { /* Only hour */ builder.append(m.group(3)); } else if (m.group(5) != null || m.group(6) != null) { /* [xxh]yym */ if (m.group(5) != null) { builder.append(m.group(5)); } else { builder.append("0"); } if (m.group(6) != null) { Formatter f = new Formatter(); f.format(Locale.US, ".%02.0f", 100 * minutesToHours(Integer.valueOf(m.group(6)))); builder.append(f.toString()); } } else { /* Only minutes >= 60 */ Formatter f = new Formatter(); f.format(Locale.US, "%.2f", minutesToHours(Integer.valueOf(m.group(7)))); builder.append(f.toString()); } return builder.toString(); }
From source file:com.richtodd.android.quiltdesign.block.Swatch.java
public String getDescription() { Formatter formatter = new Formatter(); try {/* w w w.j a va 2 s. c o m*/ formatter.format("#%02x%02x%02x", Color.red(m_color), Color.green(m_color), Color.blue(m_color)); return formatter.toString(); } finally { formatter.close(); } }
From source file:org.efaps.ui.wicket.models.EmbeddedLink.java
/** * Getter method for the instance variable {@link #tag}. * * @return value of instance variable {@link #tag} *//*from w ww . jav a2 s .c o m*/ public String getTag() { String ret = this.tag; final Formatter formatter = new Formatter(); formatter.format(ret, getId()); ret = formatter.toString(); formatter.close(); return ret; }
From source file:org.apache.sqoop.io.SplittingOutputStream.java
/** Initialize the OutputStream to the next file to write to. *//*from w w w. j av a2 s .c o m*/ private void openNextFile() throws IOException { StringBuffer sb = new StringBuffer(); Formatter fmt = new Formatter(sb); fmt.format("%05d", this.fileNum++); String filename = filePrefix + fmt.toString(); if (codec != null) { filename = filename + codec.getDefaultExtension(); } Path destFile = new Path(destDir, filename); FileSystem fs = destFile.getFileSystem(conf); LOG.debug("Opening next output file: " + destFile); if (fs.exists(destFile)) { Path canonicalDest = destFile.makeQualified(fs); throw new IOException("Destination file " + canonicalDest + " already exists"); } OutputStream fsOut = fs.create(destFile); // Count how many actual bytes hit HDFS. this.countingFilterStream = new CountingOutputStream(fsOut); if (codec != null) { // Wrap that in a compressing stream. this.writeStream = codec.createOutputStream(this.countingFilterStream); } else { // Write to the counting stream directly. this.writeStream = this.countingFilterStream; } }
From source file:com.cloudera.sqoop.io.SplittingOutputStream.java
/** Initialize the OutputStream to the next file to write to. *//*from w ww . jav a2 s . com*/ private void openNextFile() throws IOException { FileSystem fs = FileSystem.get(conf); StringBuffer sb = new StringBuffer(); Formatter fmt = new Formatter(sb); fmt.format("%05d", this.fileNum++); String filename = filePrefix + fmt.toString(); if (this.doGzip) { filename = filename + ".gz"; } Path destFile = new Path(destDir, filename); LOG.debug("Opening next output file: " + destFile); if (fs.exists(destFile)) { Path canonicalDest = destFile.makeQualified(fs); throw new IOException("Destination file " + canonicalDest + " already exists"); } OutputStream fsOut = fs.create(destFile); // Count how many actual bytes hit HDFS. this.countingFilterStream = new CountingOutputStream(fsOut); if (this.doGzip) { // Wrap that in a Gzip stream. this.writeStream = new GZIPOutputStream(this.countingFilterStream); } else { // Write to the counting stream directly. this.writeStream = this.countingFilterStream; } }
From source file:org.openecomp.sdc.common.config.AbsEcompErrorManager.java
private EcompErrorInfo setDescriptionParams(EcompErrorInfo ecompErrorInfo, String ecompErrorName, String... descriptionParams) { String description = ecompErrorInfo.getDescription(); // Counting number of params in description int countMatches = StringUtils.countMatches(description, PARAM_STR); // Catching cases when there are more params passed than there are in // the description (formatter will ignore extra params and won't throw // exception) if (countMatches != descriptionParams.length) { return getErrorInfoForDescriptionParamsMismatch(ecompErrorName); }/* w w w . j a v a 2 s. c om*/ // Setting params of the description if any StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); try { formatter.format(description, (Object[]) descriptionParams).toString(); ecompErrorInfo.setDescription(formatter.toString()); } catch (IllegalFormatException e) { // Number of passed params doesn't match number of params in config // file return getErrorInfoForDescriptionParamsMismatch(ecompErrorName); } finally { formatter.close(); } return ecompErrorInfo; }