Formatter toString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Formatter toString method.

This code example shows how to use the following methods:flush, format, toString
This code example shows how to use the following methods:flush, format, toString
    return formatData(JSON_FORMAT);
  } 
 
  private String formatData(String formatStr)
  { 
    Formatter fmt = new Formatter();
    fmt.format(formatStr,
               _config.getCapacity(), _config.getBucketsNum(), _config.getDropNum(),
               1.0 * _addTime / (2.0 * DATA_POINTS_NUM) - _procTime / 300000.0 ,
               1.0 * _calcTime);
    fmt.flush();
    return fmt.toString();
  } 
 
  @Override 
  public String toString()
  { 
    return toJsonString(); 
  } 
 
8
CodeRank
This code example shows how to use the following methods:format, toString
        try { 
            distroUrl = getProperty("urlRoot") + "/"
                    + getProperty("distributionName") + "-" 
                    + getProperty("distributionVersion") + "-" 
                    + getProperty("distributionClassifier") + ".zip"; 
            Formatter formatter = new Formatter();
            formatter.format("Wrapper properties file '%s' contains deprecated entries 'urlRoot', 'distributionName', 'distributionVersion' and 'distributionClassifier'. These will be removed soon. Please use '%s' instead.%n", propertiesFile, DISTRIBUTION_URL_PROPERTY);
            warningOutput.append(formatter.toString());
        } catch (Exception e) {
            //even the deprecated properties are not provided, report error: 
            reportMissingProperty(DISTRIBUTION_URL_PROPERTY);
        } 
        return new URI(distroUrl);
    } 
 
    private static void loadProperties(File propertiesFile, Properties properties) throws IOException {
        InputStream inStream = new FileInputStream(propertiesFile);
        try { 
            properties.load(inStream);
        } finally { 
7
CodeRank
This code example shows how to use the following methods:flush, format, toString
This code example shows how to use the following methods:flush, format, toString
    return formatData(JSON_FORMAT);
  } 
 
  private String formatData(String formatStr)
  { 
    Formatter fmt = new Formatter();
    fmt.format(formatStr,
               _config.getCapacity(), _config.getBucketsNum(), _config.getDropNum(),
               1.0 * _addTime / (2.0 * DATA_POINTS_NUM) - _procTime / 300000.0 ,
               1.0 * _calcTime);
    fmt.flush();
    return fmt.toString();
  } 
 
  @Override 
  public String toString()
  { 
    return toJsonString(); 
  } 
 
7
CodeRank
This code example shows how to use the following methods:close, format, toString
 */ 
public class NumberRenderer implements AttributeRenderer { 
    public String toString(Object o, String formatString, Locale locale) {
        // o will be instanceof Number 
        if ( formatString==null ) return o.toString();
        Formatter f = new Formatter(locale);
        f.format(formatString, o);
        String result = f.toString();
        f.close();
		return result;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:format, toString
    return (getTimeInMillis() > when);
  } 
 
  @Override 
  public String toString() {
    Formatter formatter = new Formatter();
    int year = get(YEAR);
    int month = get(MONTH)+1;
    int day = get(DAY_OF_MONTH);
    int hour = get(HOUR_OF_DAY);
    int min = get(MINUTE);
    int second = get(SECOND);
    if (date) {
      formatter.format("%04d-%02d-%02d", year, month, day);
    } else { 
      long offset = getTimeZone().getOffset(getTimeInMillis()) / (60000L);
      int hoffset = (int) (offset / 60L);
      int minoffset = (int) (offset % 60L);
      if (offset == 0) {
        formatter.format("%04d-%02d-%02dT%02d:%02d:%02dZ", year, month, day, hour, min,

6
CodeRank
This code example shows how to use the following methods:format, toString
	public String getRawMessage() {
		return super.getMessage(); 
	} 
 
	public String getMessage() {
		Formatter fmt = new Formatter();
		fmt.format("Error: ");
		if (fileName != null)
			fmt.format("(%s:%d): ", fileName, lineNumber);
 
		fmt.format(super.getMessage());
		return fmt.toString();
	} 
} 
6
CodeRank
This code example shows how to use the following methods:format, toString
      throws IOException 
    { 
      File parserFile = File.createTempFile("parser", ".ser.gz");
      File textFile = File.createTempFile("parser", ".txt");
 
      Formatter commandLineFormatter = new Formatter();
      // Note that we test on the train path.  The goal is we should 
      // get 100% accuracy if everything worked.  We will test on 
      // unknown trees in the next step. 
      commandLineFormatter.format(baseCommandLine, parserFile.getPath(),
                                  textFile.getPath(), trainPath, trainPath);
      String[] trainCommandLine =
        commandLineFormatter.toString().split("\\s+");
 
      ParserTestCase test = new ParserTestCase(trainCommandLine, testPath,
                                               parserFile, textFile);
      return test;
    } 
 
    public static ParserTestCase 
6
CodeRank
This code example shows how to use the following methods:format, toString
      return baseDate.add( value, periodField);
  } 
 
  @Override 
  public String toString() {
    Formatter f = new Formatter();
    if (isCalendarField) f.format("%s", byCalendarString);
    f.format("%s since %s", unitString, CalendarDateFormatter.toDateTimeString(baseDate));
    return f.toString();
  } 
 
  public CalendarDate getBaseCalendarDate() { 
    return baseDate;
  } 
 
  public CalendarPeriod getTimeUnit() { 
    return CalendarPeriod.of(1, CalendarPeriod.fromUnitString(unitString));
  } 
 
  public Calendar getCalendar() {
6
CodeRank
toString Method Overview
Returns the result of invoking toString() on the destination for the output.
See Code Examples for other Java 8 Formatter Methods: