public void initilize2() { int i; msg = s2.toCharArray(); for (i = 0; i < s2.length(); i++) { try { dos.write(msg[i]); // System.out.print(msg[i]); } catch (Exception e) { System.out.print("init 2 send" + e); } } try { while ((rs = dis.readLine()) != null) { // System.out.println(rs); if (rs.equals("OK")) { break; } if (rs.equals("ERROR")) { break; } } } catch (Exception e) { System.out.println("init 2 rec" + e); } }
public void read() { int i, j, k; String temp = ""; String temp1 = ""; msg = s3.toCharArray(); for (i = 0; i < s3.length(); i++) { try { dos.write(msg[i]); // System.out.println(msg[i]); } catch (Exception e) { System.out.print("read send" + e); } } try { while ((rs = dis.readLine()) != null) { temp += rs; if (rs.equals("OK")) break; if (rs.equals("ERROR")) break; } k = 0; StringTokenizer t = new StringTokenizer(temp, "\""); while (t.hasMoreTokens()) { temp1 = "" + t.nextToken().trim(); k++; if (k == 7) { System.out.println(temp1); VoiceManager voiceManager = VoiceManager.getInstance(); Voice helloVoice = voiceManager.getVoice("kevin"); helloVoice.allocate(); helloVoice.speak(temp1); helloVoice.deallocate(); } } } catch (Exception e) { System.out.print("read rec" + e); } }
public void delete() { int i; msg = s4.toCharArray(); try { for (i = 0; i < s4.length(); i++) { dos.write(msg[i]); System.out.print(msg[i]); } } catch (Exception e) { System.out.print("del send" + e); } try { while ((rs = dis.readLine()) != null) { System.out.println(rs); if (rs.equals("OK")) break; if (rs.equals("ERROR")) break; if (rs.equals("+CMS ERROR: 321")) break; } } catch (Exception e) { System.out.print("del rec" + e); } }