标签:rgs except str [] style ext static pre nbsp
String info ="good good study day day up";
StringReader stringReader = new StringReader(info);
//流标记器,处理标记,例如空格
StreamTokenizer st = new StreamTokenizer(stringReader);
例子
import java.io.*; public class file { public static void main(String[] args) { stringReader(); } private static void stringReader() { String info ="good good study day day up"; StringReader stringReader = new StringReader(info); //流标记器,处理标记,例如空格 StreamTokenizer st = new StreamTokenizer(stringReader); int count = 0; while (st.ttype != StreamTokenizer.TT_EOF){ try { if(st.nextToken() == StreamTokenizer.TT_WORD){ count ++ ; } } catch (IOException e) { e.printStackTrace(); } } stringReader.close(); System.out.println("count="+count); } }
标签:rgs except str [] style ext static pre nbsp
原文地址:https://www.cnblogs.com/mm163/p/10661865.html