Im trying to apply the streamtokenzier on this string ex: 10+5 however it only recognizes 10 and 5 as numbers but it doesn't recognize the + as word does anybody know why? I will using it later to parse mathematical equations
Output in netbeans 6.8:tokenizer.eolIsSignificant(true); ...... try { while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) { if (tokenizer.ttype == StreamTokenizer.TT_NUMBER) { System.out.println("number is :" tokenizer.nval "\n"); } else if (tokenizer.ttype == StreamTokenizer.TT_WORD){ System.out.println("word is :" tokenizer.sval + "\n"); } } } catch (IOException ex) { ex.printStackTrace(); }
number is :10.0
number is :5.0