--- a/jdk/test/java/io/StreamTokenizer/Comment.java Fri Jun 18 20:59:13 2010 +0100
+++ b/jdk/test/java/io/StreamTokenizer/Comment.java Sat Jun 19 15:17:36 2010 +0100
@@ -41,40 +41,45 @@
int slashStarComment = 4;
for (int i = 0; i < 8 ; i++) {
- StreamTokenizer st = new StreamTokenizer(new FileReader(f));
-
- /* decide the state of this run */
- boolean slashCommentFlag = ((i & slashIsCommentStart) != 0);
- boolean slashSlashCommentFlag = ((i & slashSlashComment) != 0);
- boolean slashStarCommentFlag = ((i & slashStarComment) != 0);
+ FileReader reader = new FileReader(f);
+ try {
+ StreamTokenizer st = new StreamTokenizer(reader);
- /* set the initial state of the tokenizer */
- if (!slashCommentFlag) {
- st.ordinaryChar('/');
- }
- st.slashSlashComments(slashSlashCommentFlag);
- st.slashStarComments(slashStarCommentFlag);
+ /* decide the state of this run */
+ boolean slashCommentFlag = ((i & slashIsCommentStart) != 0);
+ boolean slashSlashCommentFlag = ((i & slashSlashComment) != 0);
+ boolean slashStarCommentFlag = ((i & slashStarComment) != 0);
+
+ /* set the initial state of the tokenizer */
+ if (!slashCommentFlag) {
+ st.ordinaryChar('/');
+ }
+ st.slashSlashComments(slashSlashCommentFlag);
+ st.slashStarComments(slashStarCommentFlag);
- /* now go throgh the input file */
- while(st.nextToken() != StreamTokenizer.TT_EOF)
- {
- String token = st.sval;
- if (token == null) {
- continue;
- } else {
- if ((token.compareTo("Error1") == 0) && slashStarCommentFlag) {
- throw new Exception("Failed to pass one line C comments!");
- }
- if ((token.compareTo("Error2") == 0) && slashStarCommentFlag) {
- throw new Exception("Failed to pass multi line C comments!");
- }
- if ((token.compareTo("Error3") == 0) && slashSlashCommentFlag) {
- throw new Exception("Failed to pass C++ comments!");
- }
- if ((token.compareTo("Error4") == 0) && slashCommentFlag) {
- throw new Exception("Failed to pass / comments!");
+ /* now go throgh the input file */
+ while(st.nextToken() != StreamTokenizer.TT_EOF)
+ {
+ String token = st.sval;
+ if (token == null) {
+ continue;
+ } else {
+ if ((token.compareTo("Error1") == 0) && slashStarCommentFlag) {
+ throw new Exception("Failed to pass one line C comments!");
+ }
+ if ((token.compareTo("Error2") == 0) && slashStarCommentFlag) {
+ throw new Exception("Failed to pass multi line C comments!");
+ }
+ if ((token.compareTo("Error3") == 0) && slashSlashCommentFlag) {
+ throw new Exception("Failed to pass C++ comments!");
+ }
+ if ((token.compareTo("Error4") == 0) && slashCommentFlag) {
+ throw new Exception("Failed to pass / comments!");
+ }
}
}
+ } finally {
+ reader.close();
}
}
}