Package java.util

Examples of java.util.Formatter.format()


 
  protected String getAuth(String id, String pwd, String service) {
    try {
      Client client = new CommonsClient();
      Formatter f = new Formatter();
      f.format(
        "Email=%s&Passwd=%s&service=%s&source=%s",
        URLEncoder.encode(id, "utf-8"),
        URLEncoder.encode(pwd, "utf-8"),
        (service != null) ? URLEncoder.encode(service, "utf-8") : "",
        URLEncoder.encode(Version.APP_NAME, "utf-8"));
View Full Code Here


    {
        Formatter formatter = new Formatter();
        int count = 0;
        while(in.hasRemaining())
        {
            formatter.format("%02x ", in.get() & 0xFF);
            if(count++ == 16)
            {
                formatter.format("\n");
                count = 0;
            }
View Full Code Here

                              final Object... args)
    {
        Error error = new Error();
        error.setCondition(framingError);
        Formatter formatter = new Formatter();
        error.setDescription(formatter.format(description, args).toString());
        return error;
    }


    private void reset()
View Full Code Here

  public void printStats()
  {
    if (0 == _winNum) _winNum = 1;
    long elapsedMs = _endTs - _startTs;
    Formatter fmt = new Formatter();
    fmt.format(GLOBAL_STATS_FORMAT, elapsedMs,
               _eventsNum, (1000.0 * _eventsNum / elapsedMs),
               _winNum, (1000.0 * _winNum / elapsedMs),
               _payloadBytes, (1000.0 * _payloadBytes / elapsedMs), _payloadBytes / _eventsNum,
               _eventBytes, (1000.0 * _eventBytes / elapsedMs),
               1.0 * _eventLagNs / (1000000L * _eventsNum));
 
View Full Code Here

  }

  private void returnComponentStatus(DatabusRequest request) throws IOException
  {
    Formatter fmt = new Formatter();
    fmt.format("{\"status\":\"%s\",\"message\":\"%s\"}\n", _status.getStatus().toString(),
               _status.getMessage());
    fmt.flush();
    request.getResponseContent().write(ByteBuffer.wrap(fmt.toString().getBytes(Charset.defaultCharset())));
  }
View Full Code Here

    }

    Formatter uriFmt = new Formatter(uriString);
    if ( null != filterStr)
    {
      uriFmt.format("/bootstrap?sources=%s&checkPoint=%s&output=binary&batchSize=%d&filter=%s",
                  _sourcesIdList, _checkpoint.toString(), _freeBufferSpace, filterStr);
    } else {
      uriFmt.format("/bootstrap?sources=%s&checkPoint=%s&output=binary&batchSize=%d",
                _sourcesIdList, _checkpoint.toString(), _freeBufferSpace);
    }
View Full Code Here

    if ( null != filterStr)
    {
      uriFmt.format("/bootstrap?sources=%s&checkPoint=%s&output=binary&batchSize=%d&filter=%s",
                  _sourcesIdList, _checkpoint.toString(), _freeBufferSpace, filterStr);
    } else {
      uriFmt.format("/bootstrap?sources=%s&checkPoint=%s&output=binary&batchSize=%d",
                _sourcesIdList, _checkpoint.toString(), _freeBufferSpace);
    }
    uriFmt.close(); //make the compiler shut up

    return error;
View Full Code Here

          outBuf = new StringBuilder(in.length() + 5*3);
          outBuf.append(in,0,i);
          formatter = new Formatter(outBuf);
        }
        //leading %, 0 padded, width 2, capital hex
        formatter.format("%%%02X",(int)c);//TODO
        formatter.close();
      }
    }
    return outBuf != null ? outBuf : in;
  }
View Full Code Here

    {
      StringBuilder resBuilder = new StringBuilder(100);
      Formatter fmt = new Formatter(resBuilder);
      try
      {
        fmt.format("{\"batchingLevel\":\"%s\",\"streamBatchSize\":%d,\"bootstrapBatchSize\":%d}",
                   _batchingLevel.toString(), _streamBatchSize, _bootstrapBatchSize);
 
        fmt.flush();
        return fmt.toString();
      }
View Full Code Here

            long hours = millis / hour;
            long minutes = (millis % hour) / minute;
            long seconds = ((millis % hour) % minute) / second;
            long milliseconds = ((millis % hour) % minute % second);
            Formatter formatter = new Formatter();
            String result = formatter.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds).toString();
            formatter.close();
            return result;
        }

    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.