java 对一行英文进行单词提取

直接上代码:

package fanyi;

import java.util.Scanner;
import java.util.StringTokenizer;

public class text {
	
	public static void handle(String eString) {
		
		StringTokenizer st = new StringTokenizer(eString,",!' '.;");
		while(st.hasMoreElements()) {
			System.out.println(st.nextElement());
		}
	}
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入英文文本:");
		String eText = sc.nextLine();
		handle(eText);
		//System.out.println(eText);
	}
}


你可能感兴趣的:(java)