public class ScanfFormat extends 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(String fmt)
Constructs a ScanfFormat class from a format string.
|
Modifier and Type | Method and Description |
---|---|
void |
set(String fmt)
Sets the contents of the object according to
the information provided in the format string.
|
public ScanfFormat(String fmt)
fmt
- Format stringIllegalArgumentException
- Malformed format stringScanfReader
public void set(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 stringIllegalArgumentException
- Malformed format stringScanfReader
Copyright © 2018. All rights reserved.