Resin 1.1
FAQ
Reference
JavaDoc
Demo
Java Tutorial
Getting Started
Configuration
Servlet
JSP
XTP/XSL
JavaScript
JS Library
Core Library
File Library
Servlet Library
Database Library
XML Library
Global
Object
Array
Boolean
Date
Function
Math
Number
Regexp
String
Printf
Printf
The `printf` function provides simple formatting, following C's `printf`. It can be used in the String Object, and in Stream writing.
% [flags][width][.prec]code
Printf Formatting
%% | Adds the character '%' itself.
%s | Format as a string.
%c | Converts a character code to a character.
%d | Formats as a decimal integer.
%o | Formats as an octal integer.
%x, %X | Formats as a hex number.
%f | Formats as a fixed floating point number.
%e, %E | Formats as a scientific notation floating point number.
%g, %G | Formats as a 'nice' floating point number.
Printf Formatting
### %%
Adds the character '%' itself.
### %s
Format as a string.
### %c
Converts a character code to a character.
String.printf("%c", 65)
A
### %d
Formats as a decimal integer.
### %o
Formats as an octal integer.
### %x, %X
Formats as a hex number.
### %f
Formats as a fixed floating point number.
String.printf("%.2f", 4312.1294);
4312.13
### %e, %E
Formats as a scientific notation floating point number.
String.printf("%.2e %.2E", 4312.1294, 4312.1294);
4.31e+03 4.31E+03
### %g, %G
Formats as a 'nice' floating point number. If the number has an exponent near 0, it formats in fixed point otherwise it formats in scientific notation.
String.printf("%g %g %G", 3.14e-8, 4312.1294, 419e17);
3.14e-08 4312.13 4.19E+19
String |  | File Library
Copyright © 1998-2000 Caucho Technology. All rights reserved. Last modified: Thu, 16 Sep 1999 14:56:48 -0700 (PDT)