import java.io.*;

//
// This provides a simple example of using a
// streamtokenizer. A text file is read in and split into numbers
// and words. Numbers and words are separated by spaces.
//

public class FileTokens {
   public static void main(String[] args) throws IOException {
	//
	// Create a file, a reader, and attach it to a tokenizer.
	//

	File inputFile = new File("record.txt");
	FileReader in = new FileReader(inputFile);
	StreamTokenizer parser = new StreamTokenizer(in);

	int token;

	//
	// While the next token is not the end of the file read it in
	// and determine if it is a string or a number.
	//

	while ((token = parser.nextToken()) != StreamTokenizer.TT_EOF)
	{	   
	    //
	    // Words are stored in the .sval variable
	    //

	    if (token == StreamTokenizer.TT_WORD) {
		String x = parser.sval;
		System.out.println("String " + x);
	    }
	    
	    //
	    // Numbers are stored in the .nval variable
	    //

	    else if (token == StreamTokenizer.TT_NUMBER) {
		double num = parser.nval;
		System.out.println("Number " + num);
	    }
	}
	in.close();
    }
}
