|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.io.FormatWriter
public class FormatWriter
The FormatWriter class has a collection of static methods for
writing formatted output to System.out.
EasyReader| Constructor Summary | |
|---|---|
FormatWriter()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
A demonstration program. |
static void |
pause(long milliseconds)
Make the computation pause for a specified number of milliseconds. |
static void |
printLeft(java.lang.Object output,
int minimumWidth)
Print an Object (such as a String) to
System.out, using left justification. |
static void |
printNumber(double d,
int minimumWidth,
int fractionDigits)
Print a number to System.out, using a specified format. |
static void |
printRight(java.lang.Object output,
int minimumWidth)
Print an Object (such as a String) to
System.out, using right justification. |
static void |
printWhole(long n,
int minimumWidth)
Print a whole number to System.out, using a specified format. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FormatWriter()
| Method Detail |
|---|
public static void pause(long milliseconds)
milliseconds - the number of milliseconds to pause
public static void printNumber(double d,
int minimumWidth,
int fractionDigits)
d - the number to be printedminimumWidth - the minimum number of characters in the entire outputfractionDigits - the number of digits to print on the right side of the decimal point
fractionDigits is not negative.
d has been printed to System.out.
This printed number is rounded to the specified number of digits on the
right of the decimal. If fractionDigits is 0, then only the
integer part of d is printed. If necessary, spaces appear
at the front of the number to raise the total number of printed
characters to the minimum. Additional formatting details are obtained
from the current locale. For example, in the United States, a period is
used for the decimal and commas are used to separate groups of
integer digits.
IllegalArgumentException - Indicates that fractionDigits is negative.
printNumber(12345.27, 8, 1);
Prints 12,345.3 in the U.S.
public static void printLeft(java.lang.Object output,
int minimumWidth)
Object (such as a String) to
System.out, using left justification.
output - the Object to be printedminimumWidth - the minimum number of characters in the entire output
Object has been printed to System.out.
If necessary, spaces appear
at the front of the Object to raise the total number of printed
characters to the minimum.
printNumber("Foo", 8);
Prints "Foo " (with 5 spaces).
public static void printRight(java.lang.Object output,
int minimumWidth)
Object (such as a String) to
System.out, using right justification.
output - the Object to be printedminimumWidth - the minimum number of characters in the entire output
Object has been printed to System.out.
If necessary, spaces appear
at the front of the Object to raise the total number of printed
characters to the minimum.
printNumber("Foo", 8);
Prints " Foo" (with 5 spaces).
public static void printWhole(long n,
int minimumWidth)
d - the number to be printedminimumWidth - the minimum number of characters in the entire output
n has been printed to System.out.
If necessary, spaces appear
at the front of the number to raise the total number of printed
characters to the minimum. Additional formatting details are obtained
from the current locale. For example, in the United States
commas are used to separate groups of
integer digits.
printNumber(12345, 8);
Prints " 12,345" in the U.S. (with 2 spaces in front)public static void main(java.lang.String[] args)
java edu.colorado.io.FormatWriter
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||