Java.io包教程

Java.io.StreamTokenizer类

简介

Java.io.StreamTokenizer 类接受输入流并将其解析为"令牌",允许在一个令牌中读取令牌时间.流标记器可以识别标识符,数字,带引号的字符串和各种注释样式.

类声明

以下是 Java的声明.io.StreamTokenizer class :

public class StreamTokenizer
   extends Object

字段

以下是 Java.io.StreamTokenizer 类 :

  • double nval:如果当前标记是数字,则该字段包含该数字的值。

  • String sval:如果当前标记是单词标记,则该字段包含一个字符串,给出单词标记的字符。

  • static int TT_EOF:一个常量,指示已读取流的末尾。

  • static int TT_EOL:一个常量,指示已读取行的结尾。

  • static int TT_NUMBER:表示已读取数字标记的常量。

  • static int TT_WORD:表示已读取字令牌的常量。

  • int ttype:调用nextToken方法后,该字段包含刚刚读取的令牌类型。

类构造函数

Sr.No.Constructor & Description
1

StreamTokenizer(Reader r)

这将创建一个解析给定字符流的标记生成器。

类方法

Sr.No.Method & Description
1void commentChar(int ch)

Specified that the character argument starts a single-line comment.

2void eolIsSignificant(boolean flag)

This method determines whether or not ends of line are treated as tokens.

3int lineno()

This method returns the current line number.

4void lowerCaseMode(boolean fl)

This method determines whether or not word token are automatically lowercased.

5int nextToken()

This method parses the next token from the input stream of this tokenizer.

6void ordinaryChar(int ch)

This method specifies that the character argument is "ordinary" in this tokenizer.

7void ordinaryChars(int low, int hi)

This method specifies that all characters c in the range low <= c <= high are "ordinary" in this tokenizer.

8void parseNumbers()

This method specifies that numbers should be parsed by this tokenizer.

9void pushBack()

This method causes the next call to the nextToken method of this tokenizer to return the current value in the ttype field, and not to modify the value in the nval or sval field.

10void quoteChar(int ch)

This method specifies that matching pairs of this character delimit string constants in this tokenizer.

11void resetSyntax()

This method resets this tokenizer's syntax table so that all characters are "ordinary." See the ordinaryChar method for more information on a character being ordinary.

12void slashSlashComments(boolean flag)

This method determines whether or not the tokenizer recognizes C++ style comments.

13void slashStarComments(boolean flag)

This method determines whether or not the tokenizer recognizes C style comments.

14String toString()

This method returns the string representation of the current stream token and the line number it occurs on.

15void whitespaceChars(int low, int hi)

This method specifies that all characters c in the range low <= c <= high are white space characters.

16void wordChars(int low, int hi)

This method specifies that all characters c in the range low <= c >= high are word constituents.

方法继承

此类继承以下类中的方法:

  • Java.io.Object