Name: mc57594 Date: 01/29/97
StreamTokenizer erroneously generates leading space in sval when
space is defined not to be a whitespace-character. Possible cause
implicit processing of peekc, which is initialized as ' ', at the beginning
of an extraction.
--- Example code follows
public class c
{
public static void main (String args[]) {
try {
BufferedInputStream input = new BufferedInputStream(new FileInputStream("D:\\VIEWER\\TB96286"));
StreamTokenizer st = new StreamTokenizer(input);
st.resetSyntax();
st.eolIsSignificant(false);
st.wordChars(0, 255);
st.ordinaryChars('+', '+');
st.ordinaryChars(':', ':');
st.ordinaryChars('\'', '\'');
st.ordinaryChars('?', '?');
String lastVal;
for (int tokenType = st.nextToken();
tokenType != StreamTokenizer.TT_EOF;
tokenType = st.nextToken()) {
switch (tokenType) {
case StreamTokenizer.TT_NUMBER:
// Not reached
break;
case StreamTokenizer.TT_WORD:
System.out.println("'" + st.sval.substring(1) + "'"); // Need to ignore spurious space at beginning - library error
lastVal = st.sval.substring(1);
break;
default: // Ordinary Character
}
}
} catch (FileNotFoundException e) {
System.out.println("File not found");
} catch (IOException e) {
System.out.println("I/O failure");
}
}
}
======================================================================
- duplicates
-
JDK-4025128 java.io.StreamTokenizer.nextToken() doesn't work when chr(32) has its white-spac
-
- Closed
-