Constructor and Description(构造函数和说明) charsetName为指定编码方式 |
---|
Scanner(File source) 扫描仪 (文件源) 构造一个新扫描仪, 它生成从指定文件扫描的值。 |
Scanner(FileRef source) 扫描仪 (FileRef 源) 构造一个新的扫描仪, 它生成从指定文件扫描的值。 |
Scanner(FileRef source, String charsetName) 构造一个新的扫描程序, 该扫描仪生成从指定文件扫描的值。 |
Scanner(File source, String charsetName) 构造一个新的扫描程序, 该扫描仪生成从指定文件扫描的值。 |
Scanner(InputStream source) 构造一个新的扫描程序, 该扫描仪生成从指定的输入流中扫描的值。 |
Scanner(InputStream source, String charsetName) 构造一个新的扫描程序, 该扫描仪生成从指定的输入流中扫描的值。 |
Scanner(Readable source) 构造一个新的扫描程序, 该扫描仪生成从指定源扫描的值 |
Scanner(ReadableByteChannel source) 构造一个新的扫描程序, 该扫描仪生成从指定通道扫描的值。 |
Scanner(ReadableByteChannel source, String charsetName) 构造一个新的扫描程序, 该扫描仪生成从指定通道扫描的值。 |
Scanner(String source) 构造一个新的扫描程序, 该扫描仪生成从指定字符串扫描的值。 |
Modifier修饰符 and Type | Method and Description pattern 模式类 delimiter 分隔符 radix 基数(指定进制) |
---|---|
void | close() 关闭此扫描仪。 |
Pattern | delimiter() 返回此扫描仪当前用于匹配模式串的分隔符。 |
String | findInLine(Pattern pattern) 尝试查找匹配指定模式的下一项, 忽略分隔符。 |
String | findInLine(String pattern) 尝试查找匹配指定字符串模式的下一项, 忽略分隔符。 |
String | findWithinHorizon(Pattern pattern, int horizon) 尝试查找匹配指定模式的下一项。 |
String | findWithinHorizon(String pattern, int horizon) 尝试查找从指定字符串构造的模式的下一个匹配项, 忽略分隔符。 |
boolean | hasNext() 如果此扫描仪的输入中有下一个标记, 则返回 true。 |
boolean | hasNext(Pattern pattern) 如果存在下一个标记与指定的模式匹配, 则返回 true。 |
boolean | hasNext(String pattern) 如果下一个标记与从指定字符串构造的模式匹配, 则返回 true。 |
boolean | hasNextBigDecimal() 如果此扫描仪输入中的下一个标记可以使用 nextBigDecimal () 方法解释为 BigDecimal, 则返回 true。 |
boolean | hasNextBigInteger() 如果此扫描仪输入中的下一个标记可以被解释为使用 nextBigInteger () 方法的默认基数中的 BigInteger, 则返回 true。 |
boolean | hasNextBigInteger(int radix) 如果此扫描仪输入中的下一个标记可以使用 nextBigInteger () 方法将其解释为指定基数中的 BigInteger, 则返回 true。 |
boolean | hasNextBoolean() 如果此扫描仪输入中的下一个标记可以使用"true | false" 创建解释为布尔值, 则返回 true。 |
boolean | hasNextByte() Returns true if the next token in this scanner's input can be interpreted as a byte value in the default radix using the nextByte() method. |
boolean | hasNextByte(int radix) Returns true if the next token in this scanner's input can be interpreted as a byte value in the specified radix using the nextByte() method. |
boolean | hasNextDouble() Returns true if the next token in this scanner's input can be interpreted as a double value using the nextDouble() method. |
boolean | hasNextFloat() Returns true if the next token in this scanner's input can be interpreted as a float value using the nextFloat() method. |
boolean | hasNextInt() Returns true if the next token in this scanner's input can be interpreted as an int value in the default radix using the nextInt() method. |
boolean | hasNextInt(int radix) Returns true if the next token in this scanner's input can be interpreted as an int value in the specified radix using the nextInt() method. |
boolean | hasNextLine() Returns true if there is another line in the input of this scanner. |
boolean | hasNextLong() Returns true if the next token in this scanner's input can be interpreted as a long value in the default radix using the nextLong() method. |
boolean | hasNextLong(int radix) Returns true if the next token in this scanner's input can be interpreted as a long value in the specified radix using the nextLong() method. |
boolean | hasNextShort() Returns true if the next token in this scanner's input can be interpreted as a short value in the default radix using the nextShort() method. |
boolean | hasNextShort(int radix) Returns true if the next token in this scanner's input can be interpreted as a short value in the specified radix using the nextShort() method. |
IOException | ioException() Returns the IOException last thrown by this Scanner 's underlying Readable . |
Locale | locale() 返回现在所处的下标 |
MatchResult | match() 返回此扫描仪上次执行扫描操作所匹配的结果。 |
String | next() 返回此扫描仪的下一个标记。 |
String | next(Pattern pattern) 如果匹配到指定模式中符合设定模式的, 则返回下一个标记。 |
String | next(String pattern) 如果匹配到指定字符串中符合设定模式的, 则返回下一个标记。 |
BigDecimal | nextBigDecimal() 将输入的下一个标记作为
类型扫描。 |
BigInteger | nextBigInteger() 将输入的下一个标记作为BigInteger 类型扫描。 |
BigInteger | nextBigInteger(int radix) 将输入的下一个标记作为BigInteger 类型扫描。 |
boolean | nextBoolean() 将输入的下一个标记作为bool类型扫描。 |
byte | nextByte() 将输入的下一个标记作为字节扫描。 |
byte | nextByte(int radix) 将输入的下一个标记作为字节扫描。 |
double | nextDouble() 将输入的下一个标记作为双精度扫描。 |
float | nextFloat() 将输入的下一个标记作为双精度扫描。 |
int | nextInt() 将输入的下一个标记作为整数扫描。 |
int | nextInt(int radix) 将输入的下一个标记作为整数扫描。 |
String | nextLine() 将此扫描仪向前推进, 并返回已跳过的字符。 |
long | nextLong() 将输入的下一个标记作为长整数扫描。 |
long | nextLong(int radix) 将输入的下一个标记作为长整数扫描。 |
short | nextShort() 将输入的下一个标记作为短整数扫描。 |
short | nextShort(int radix) 将输入的下一个标记作为短整数扫描。 |
int | radix() 返回此扫描仪的默认基数。 |
void | remove() 迭代器的实现不支持移除操作。 |
Scanner | reset() 重启扫描仪 |
Scanner | skip(Pattern pattern) 跳过与指定模式匹配的输入项, 忽略分隔符。 |
Scanner | skip(String pattern) 跳过与指定字符串匹配的输入项 |
String | toString() 返回此扫描仪的字符串表示形式 |
Scanner | useDelimiter(Pattern pattern) 将此扫描仪的分隔模式设置为指定的模式。 |
Scanner | useDelimiter(String pattern) 将此扫描仪分隔设置为指定字符串。 |
Scanner | useLocale(Locale locale) 将此扫描仪当前下标设置设为指定的下标。 |
Scanner | useRadix(int radix) 将此扫描仪的默认基数设置为指定基数。 |
含有 radix的为指定进制,含有pattern的为模式串 ,使用delimiter为指定分隔符 ,locate为指定下标。
方法nextByte()、nextShort()、nextInt()、nextLong()、nextFloat()、nextDouble()、next()等都称为标记读取方法(token-reading method),因为它们会读取用分隔符分隔开的标记。默认情况下,分隔符是空格。
方法next()和nextLine()都会读取一个字符串。next()方法读取一个由分隔符分隔的字符串,但是nextLine()读取一个以换行符结束的行。
标记读取方法不能读取标记后面的分隔符。
如果在标记读取方法之后调用nextLIne(),该方法读取从这个分隔符开始,到这行的行分隔符结束的字符。这个行分隔符也被读取,但是它不是nextLIne()返回的字符串部分。