提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用StringTokenizer读取字符串标记
import java.util.StringTokenizer; public class Main {/*n o w j a v a . c o m 提供*/ public static void main(String[] arguments) { StringTokenizer st1, st2; String quote1 = "AAAA 604.43 -0.42"; st1 = new StringTokenizer(quote1); System.out.println("Token 1: " + st1.nextToken()); System.out.println("Token 2: " + st1.nextToken()); System.out.println("Token 3: " + st1.nextToken()); /** * 时 代 J a v a 公 众 号 提 供 **/ String quote2 = "AAA@60.39@0.11"; st2 = new StringTokenizer(quote2, "@"); System.out.println("\nToken 1: " + st2.next