⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javaio.doc12.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a name="29335"></a>
<li>Single quote <code>'\''</code> and double quote <code>'"'</code> are string quote characters.
<a name="29336"></a>
<li>Numbers are parsed.
<a name="29337"></a>
<li>End of line is not significant.
<a name="29338"></a>
<li><code>//</code> comments and <code>/*</code> comments are not recognized.
</ul><a name="29339"></a>
<p><font size=+1><strong>22.14.9   </strong> <code>public void <code><b>resetSyntax</b></code>()</code></font>
<p>
<a name="29340"></a>
The syntax table for this <code>StreamTokenizer</code> is reset so that every byte value is 
"ordinary"; thus, no character is recognized as being a whitespace, alphabetic, 
numeric, string quote, or comment character. Calling this method is therefore 
equivalent to:
<p><pre><a name="29341"></a>ordinaryChars(0x00, 0xff)
</pre><a name="29342"></a>
The three flags controlling recognition of line terminators, <code>//</code> comments, and <code>/*</code> 
comments are unaffected.
<p><a name="29343"></a>
<p><font size=+1><strong>22.14.10   </strong> <code>public void <code><b>wordChars</b></code>(int low, int hi)</code></font>
<p>
<a name="29344"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that every character in 
the range <code>low</code> through <code>hi</code> has the "alphabetic" attribute.
<p><a name="29345"></a>
<p><font size=+1><strong>22.14.11   </strong> <code>public void <code><b>whitespaceChars</b></code>(int low, int hi)</code></font>
<p>
<a name="29346"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that every character in 
the range <code>low</code> through <code>hi</code> has the "whitespace" attribute.
<p><a name="29347"></a>
<p><font size=+1><strong>22.14.12   </strong> <code>public void <code><b>ordinaryChars</b></code>(int low, int hi)</code></font>
<p>
<a name="29348"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that every character in 
the range <code>low</code> through <code>hi</code> has no attributes.
<p><a name="29349"></a>
<p><font size=+1><strong>22.14.13   </strong> <code>public void <code><b>ordinaryChar</b></code>(int ch)</code></font>
<p>
<a name="29350"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that the character <code>ch</code> 
has no attributes.
<p><a name="29351"></a>
<p><font size=+1><strong>22.14.14   </strong> <code>public void <code><b>commentChar</b></code>(int ch)</code></font>
<p>
<a name="29352"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that the character <code>ch</code> 
has the "comment character" attribute.
<p><a name="29353"></a>
<p><font size=+1><strong>22.14.15   </strong> <code>public void <code><b>quoteChar</b></code>(int ch)</code></font>
<p>
<a name="29354"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that the character <code>ch</code> 
has the "string quote" attribute.
<p><a name="29355"></a>
<p><font size=+1><strong>22.14.16   </strong> <code>public void <code><b>parseNumbers</b></code>()</code></font>
<p>
<a name="29356"></a>
The syntax table for this <code>StreamTokenizer</code> is modified so that each of the twelve 
characters
<p><pre><a name="29357"></a>0 1 2 3 4 5 6 7 8 9 . -
</pre><a name="29358"></a>
has the "numeric" attribute.
<p><a name="29359"></a>
<p><font size=+1><strong>22.14.17   </strong> <code>public void <code><b>eolIsSignificant</b></code>(boolean flag)</code></font>
<p>
<a name="29360"></a>
This <code>StreamTokenizer</code> henceforth recognizes line terminators as tokens if and 
only if the <code>flag</code> argument is <code>true</code>.
<p><a name="29361"></a>
<p><font size=+1><strong>22.14.18   </strong> <code>public void <code><b>slashStarComments</b></code>(boolean flag)</code></font>
<p>
<a name="32384"></a>
This <code>StreamTokenizer</code> henceforth recognizes and skips Java-style "traditional" 
comments, which are delimited by <code>/*</code> and <code>*/</code> and do not nest, if and only if the 
<code>flag</code> argument is <code>true</code>.
<p><a name="29363"></a>
<p><font size=+1><strong>22.14.19   </strong> <code>public void <code><b>slashSlashComments</b></code>(boolean flag)</code></font>
<p>
<a name="32380"></a>
This <code>StreamTokenizer</code> henceforth recognizes and skips Java-style end-of-line 
comments that start with <code>//</code> if and only if the <code>flag</code> argument is <code>true</code>.
<p><a name="29365"></a>
<p><font size=+1><strong>22.14.20   </strong> <code>public void <code><b>lowerCaseMode</b></code>(boolean flag)</code></font>
<p>
<a name="29366"></a>
This <code>StreamTokenizer</code> henceforth converts all the characters in identifiers to 
lowercase if and only if the <code>flag</code> argument is <code>true</code>.
<p><a name="29367"></a>
<p><font size=+1><strong>22.14.21   </strong> <code>public int <code><b>nextToken</b></code>() throws IOException</code></font>
<p>
<a name="29371"></a>
If the previous token was pushed back <a href="javaio.doc12.html#29383">(&#167;22.14.22)</a>, then the value of <code>ttype</code> is 
returned, effectively causing that same token to be reread.
<p><a name="29372"></a>
Otherwise, this method parses the next token in the contained input stream. The type of the token is returned; this same value is also made available in the <code>ttype</code> field, and related data may be made available in the <code>sval</code> and <code>nval</code> fields.<p>
<a name="29373"></a>
First, whitespace characters are skipped, except that if a line terminator is encountered and this <code>StreamTokenizer</code> is currently recognizing line terminators, then the type of the token is <code>TT_EOL</code>.<p>
<a name="29375"></a>
If a numeric character is encountered, then an attempt is made to recognize a number. If the first character is <code>'-'</code> and the next character is not numeric, then the <code>'-'</code> is considered to be an ordinary character and is recognized as a token in its own right. Otherwise, a number is parsed, stopping before the next occurrence of <code>'-'</code>, the second occurrence of <code>'.'</code>, the first nonnumeric character encountered, or end of file, whichever comes first. The type of the token is <code>TT_NUMBER</code> and its value is made available in the field <code>nval</code>.<p>
<a name="29376"></a>
If an alphabetic character is encountered, then an identifier is recognized, consisting of that character and all following characters up to, but not including, the first character that is neither alphabetic nor numeric, or up to end of file, whichever comes first. The characters of the identifier may be converted to lowercase if this <code>StreamTokenizer</code> is in lowercase mode.<p>
<a name="29377"></a>
If a comment character is encountered, then all subsequent characters are skipped and ignored, up to but not including the next line terminator or end of file. Then another attempt is made to recognize a token. If this <code>StreamTokenizer</code> is currently recognizing line terminators, then a line terminator that ends a comment will be recognized as a token in the same manner as any other line terminator in the contained input stream.<p>
<a name="29378"></a>
If a string quote character is encountered, then a string is recognized, consisting of all characters after (but not including) the string quote character, up to (but not including) the next occurrence of that same string quote character, or a line terminator, or end of file. The usual escape sequences <a href="3.doc.html#101089">(&#167;3.10.6)</a> such as <code>\n</code> and <code>\t</code> are recognized and converted to single characters as the string is parsed.<p>
<a name="29379"></a>
If <code>//</code> is encountered and this <code>StreamTokenizer</code> is currently recognizing <code>//</code> comments, then all subsequent characters are skipped and ignored, up to but not including the next line terminator or end of file. Then another attempt is made to recognize a token. (If this <code>StreamTokenizer</code> is currently recognizing line terminators, then a line terminator that ends a comment will be recognized as a token in the same manner as any other line terminator in the contained input stream.)<p>
<a name="29380"></a>
If <code>/*</code> is encountered and this <code>StreamTokenizer</code> is currently recognizing <code>/*</code> comments, then all subsequent characters are skipped and ignored, up to and including the next occurrence of <code>*/</code> or end of file. Then another attempt is made to recognize a token.<p>
<a name="29381"></a>
If none of the cases listed above applies, then the only other possibility is that the first non-whitespace character encountered is an ordinary character. That character is considered to be a token and is stored in the <code>ttype</code> field and returned.<p>
<a name="29383"></a>
<p><font size=+1><strong>22.14.22   </strong> <code>public void <code><b>pushBack</b></code>()</code></font>
<p>
<a name="29384"></a>
Calling this method "pushes back" the current token; that is, it causes the next call 
to <code>nextToken</code> to return the same token that it just provided. Note that this method 
does <i>not</i> restore the line number to its previous value, so if the method <code>lineno</code> is 
called after a call to <code>pushBack</code> but before the next call to <code>nextToken</code>, an incorrect 
line number may be returned.
<p><a name="29385"></a>
<p><font size=+1><strong>22.14.23   </strong> <code>public int <code><b>lineno</b></code>()</code></font>
<p>
<a name="29386"></a>
The number of the line on which the current token appeared is returned. The first 
token in the input stream, if not a line terminator, is considered to appear on line <code>1</code>. 
A line terminator token is considered to appear on the line that it precedes, not on 
the line it terminates; thus, the first line terminator in the input stream is considered
to be on line <code>2</code>.
<p><a name="29387"></a>
<p><font size=+1><strong>22.14.24   </strong> <code>public String <code><b>toString</b></code>()</code></font>
<p>
<a name="33254"></a>
The current token and the current line number are converted to a string of the 
form:
<p><pre><a name="33255"></a>"Token[<i>x</i>], line <i>m</i>"
</pre><a name="33256"></a>
where <i>m</i> is the current line number in decimal form and <i>x</i> depends on the type of 
the current token:
<p><ul><a name="32713"></a>
<li>If the token type is <code>TT_EOF</code>, then <i>x</i> is "<code>EOF</code>".
<a name="32715"></a>
<li>If the token type is <code>TT_EOL</code>, then <i>x</i> is "<code>EOL</code>".
<a name="32717"></a>
<li>If the token type is <code>TT_WORD</code>, then <i>x</i> is the current value of <code>sval</code> <a href="javaio.doc12.html#29326">(&#167;22.14.6)</a>.
<a name="32719"></a>
<li>If the token type is <code>TT_NUMBER</code>, then <i>x</i> is "<code>n=</code>" followed by the result of converting the current value of <code>nval</code> <a href="javaio.doc12.html#29328">(&#167;22.14.7)</a> to a string <a href="javalang.doc9.html#5899">(&#167;20.10.15)</a>.
</ul><a name="32709"></a>
Overrides the <code>toString</code> method of <code>Object</code> <a href="javalang.doc1.html#1152">(&#167;20.1.2)</a>.<p>


<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javaio.doc11.html">Prev</a> | <a href="javaio.doc13.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<p>
<font size=-1>Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)<br>
<i><a href="jcopyright.doc.html">Copyright &#169 1996 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a>
</font>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -