|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Throwable | +--java.lang.Exception | +--java.lang.RuntimeException | +--java.lang.IllegalArgumentException | +--lava.clib.stdio.PrintfFormatException
Indicates malformed printf format string.
Details: Printf for Java throws a PrintfFormatException when formatting is attempted through an invalid format string. This exception almost always indicates a bug in the client code.
Example:
float tax_increase = SOME_VALUE; Stdio.printf ( "taxes raised by %f% this year", new Object [] { new Float (tax_increase) } );When this code is executed, the format string parser interprets the second percent character as the beginning of a second format specifier. But since the following character, 't', does not correspond to a legal printf conversion type, a
PrintfFormatException
will be thrown. (The correct format string should read "taxes raised by %f%% this year".)
Even if a format string is syntactically correct, a PrintfFormatException
can still be thrown if variable widths and precisions are used, and the supplied values are invalid.
Example:
int dec_places = SOME_VALUE; Stdio . printf ( "pi rounded to %d decimal places is %.*f", new Va_args (3) . add (dec_places) . add (dec_places) . add (Math.PI) . done (); );This code throws a
PrintfFormatException
ifdec_places
is negative.
For more information on printf formatting, see lava.clib.stdio.Printf
.
Printf
,
Stdio
, Serialized FormMethods inherited from class java.lang.Throwable |
fillInStackTrace,
getLocalizedMessage,
getMessage,
printStackTrace,
printStackTrace,
printStackTrace,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |