public class ScanfFormat
extends java.lang.Object
A scanf style format string is specified in the constructor. Once instantiated, objects of this class may be passed as arguments to the scan methods of the ScanfReader class.
ScanfReader| Modifier and Type | Field and Description |
|---|---|
int |
type |
| Constructor and Description |
|---|
ScanfFormat(java.lang.String fmt)
Constructs a ScanfFormat class from a format string.
|
| Modifier and Type | Method and Description |
|---|---|
void |
set(java.lang.String fmt)
Sets the contents of the object according to
the information provided in the format string.
|
public ScanfFormat(java.lang.String fmt)
fmt - Format stringjava.lang.IllegalArgumentException - Malformed format stringScanfReaderpublic void set(java.lang.String fmt)
The format string describes what input to expect for a ScanfReader, and its form closely matches that for the C scanf methodName, expect that multiple conversions cannot be specified.
A conversion sequence is introduced by the '%' character; valid conversion sequences are described below. Other characters may appear in the format string. A white space character requests a match of any amount of white space, including none. Other characters request an exact match of themselves. The character sequence "%%" requests a match of the '%' character.
The '%' character introducing a conversion sequence may be followed by an unsigned decimal integer indicating the field width, which is the maximum number of characters used for a particular conversion. Field widths must be greater than 0.
The optional field width is followed by one of the following conversion characters, which specifies the primitive type to be scanned:
fmt - Format stringjava.lang.IllegalArgumentException - Malformed format stringScanfReader