Hi, I'm using StreamTokenizer to read contents from a text file. I want to retain the spaces in the text file, but streamtokenizer removes the spaces and appends all the characters in the file. I tried using ordinaryChar() method, but that didn't really help either. Any suggestions would really help...
Reader read = new BufferedReader(new InputStreamReader(myFile));//read the contents using buffered reader StreamTokenizer in = new StreamTokenizer(read); //read the tokens in.ordinaryChar(' ');
I don't think StreamTokenizer returns the delimiters (i.e. the spaces) to you. Why do you need them anyways? If you can explain your reasoning here, we might be able to help you find an alternate solution. Perhaps StringTokenizer will help, but I'm unsure that this is what you really need.
will return the space character which you handle as below in the switch stmt: case ' ':
Joined: Oct 02, 2005
Hi, My program has to choose random sentences based on a randomly generated line number from a text file. I thought using StreamTokenizer will help me use the lineno() function for selecting a random line number. Anyways, I'm gonna try the case ' ' option and see how it works...