/Users/lyon/j4p/src/addBk/addressBook/DosDialer.java
|
1 package addBk.addressBook;
2
3 //DialPanel.javaDialPanel.java
4
5 import java.io.BufferedReader;
6 import java.io.IOException;
7 import java.io.InputStreamReader;
8 import java.util.StringTokenizer;
9
10 public class DosDialer {
11
12 public DosDialer(int dialerNumber) {
13 try {
14 dial(getPhoneNumber(dialerNumber));
15 } catch (IOException e) {
16 System.out.println("IOERROR: " + e.getMessage());
17 }
18 }
19
20 public static void dial(String batchParameter)
21 throws IOException {
22 String batchFile = "dial.bat";
23 Runtime rt
24 = Runtime.getRuntime();
25 Process p = rt.exec(batchFile + " " + batchParameter);
26
27 BufferedReader br
28 = new BufferedReader(
29 new InputStreamReader(
30 p.getInputStream()));
31 String s = null;
32 while ((s = br.readLine()) != null)
33 System.out.println("dos:" + s);
34
35 }
36
37
38 public String getPhoneNumber(int dialerNumber) {
39 AddressBookMediator display =
40 new AddressBookMediator();
41 AddressBookRecord abr =
42 display.getTextFieldValues();
43 if (dialerNumber == 1)
44 return (getNumbers(abr.dial_1));
45 else if (dialerNumber == 2)
46 return (getNumbers(abr.dial_2));
47 else if (dialerNumber == 3)
48 return (getNumbers(abr.dial_3));
49 else
50 return ("");
51 }
52
53 public static String getNumbers(String line) {
54 String numbers = "";
55
56 StringTokenizer st =
57 new StringTokenizer(line, "()-");
58 while (st.countTokens() > 0) {
59 numbers = numbers + st.nextToken();
60 }
61 return (numbers);
62 }
63
64 }
65