/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import java.awt.event.* ; 

2. import java.awt.* ; 

3. import java.applet.*; 

4. import java.util.StringTokenizer

5. import java.util.Enumeration

6.  

7. public class StringSplit 

8.   extends Applet 

9.   implements ActionListener 

10.

11.   StringTokenizer stok ; 

12.  

13.   public void actionPerformed( ActionEvent ev ) 

14.   { 

15.    String ssplit1 = "Chuck   the \t\t whitespace \n ,Drax"

16.    String swork ; 

17.  

18.    stok = new StringTokenizer( ssplit1 ) ; 

19.    while ( stok.hasMoreElements() ) 

20.    { 

21.      swork = (String) stok.nextElement() ; 

22.      ta.append( swork + '\n' ); 

23.    } 

24.  

25.    String ssplit2 = "j.bond@mi5.gov.uk"

26.    stok = new StringTokenizer 

27.         ( ssplit2 ,   ".@"   ) ; 

28.  

29.    ta.append( "=============\n" ); 

30.    while ( stok.hasMoreElements() ) 

31.    { 

32.      swork = (String) stok.nextElement() ; 

33.      ta.append( swork + '\n' ); 

34.    } 

35.   } 

36.  

37.   public StringSplit () 

38.   { 

39.     bt = new Button ( "Split'm" ) ; 

40.     ta = new TextArea (  12, 35 ) ; 

41.     add( bt ) ; add( ta ) ; 

42.     bt.addActionListener( this ) ; 

43.   } 

44.  

45.   TextArea ta ; 

46.   Button bt ; 

47.

48.