|
Colt 1.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--corejava.Format
A class for formatting numbers that follows printf conventions. Also implements C-like atoi and atof functions. Formats the number following printf conventions. Main limitation: Can only handle one format parameter at a time. Use multiple Format objects to format more than one number.
Constructor Summary | |
Format(String s)
Constructs and returns a new format instance. |
Method Summary | |
static double |
atof(String s)
Converts a string of digits to an double |
static int |
atoi(String s)
Converts a string of digits (decimal, octal or hex) to an integer |
static long |
atol(String s)
Converts a string of digits (decimal, octal or hex) to a long integer |
String |
form(char c)
Formats a character into a string (like sprintf in C) |
String |
form(double x)
Formats a double into a string (like sprintf in C) |
String |
form(long x)
Formats a long integer into a string (like sprintf in C) |
String |
form(String s)
Formats a string into a larger string (like sprintf in C) |
static void |
main(String[] a)
a test stub for the format class |
static void |
print(PrintStream s,
String fmt,
char x)
prints a formatted number following printf conventions |
static void |
print(PrintStream s,
String fmt,
double x)
prints a formatted number following printf conventions |
static void |
print(PrintStream s,
String fmt,
long x)
prints a formatted number following printf conventions |
static void |
print(PrintStream s,
String fmt,
String x)
prints a formatted number following printf conventions |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Format(String s)
s
- the format string following printf conventions.
The string has a prefix, a format code and a suffix. The prefix and suffix
become part of the formatted output. The format code directs the
formatting of the (single) parameter to be formatted. The code has the
following structure
IllegalArgumentException
- if bad formatMethod Detail |
public static double atof(String s)
s
- a stringpublic static int atoi(String s)
s
- a stringpublic static long atol(String s)
s
- a stringpublic String form(char c)
x
- the value to formatpublic String form(double x)
x
- the number to formatIllegalArgumentException
- if bad argumentpublic String form(long x)
x
- the number to formatpublic String form(String s)
x
- the value to formatpublic static void main(String[] a)
public static void print(PrintStream s, String fmt, char x)
s
- a PrintStreamfmt
- the format stringx
- the character topublic static void print(PrintStream s, String fmt, double x)
s
- a PrintStreamfmt
- the format stringx
- the double to printpublic static void print(PrintStream s, String fmt, long x)
s
- a PrintStreamfmt
- the format stringx
- the long to printpublic static void print(PrintStream s, String fmt, String x)
s
- a PrintStream, fmt the format stringx
- a string that represents the digits to print
|
Colt 1.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |