public class DelimitersDemo
1:
2: import java.util.Scanner;
3:
4: public class DelimitersDemo
5: {
6: public static void main(String[] args)
7: {
8: Scanner keyboard1 = new Scanner(System.in);
9: Scanner keyboard2 = new Scanner(System.in);
10:
11: keyboard2.useDelimiter("##");
12: //The delimiters for keyboard1 are the white space characters.
13: //The only delimiter for keyboard2 is ##.
14:
15: String s1, s2;
16:
17: System.out.println("Enter a line of text with two words:");
18: s1 = keyboard1.next( );
19: s2 = keyboard1.next( );
20: System.out.println("The two words are \"" + s1 +
21: "\" and \"" + s2 + "\"");
22:
23: System.out.println("Enter a line of text with two words");
24: System.out.println("delimited by ##:");
25: s1 = keyboard2.next( );
26: s2 = keyboard2.next( );
27: System.out.println("The two words are \"" + s1 +
28: "\" and \"" + s2 + "\"");
29: }
30: }
31: