// Copyright 2002 Visualtron Software Corporation // Source File Name: SendSMS.java // // Ensure that csend.exe or dll is given execution rights under IIS Manager import java.io.*; import java.net.*; import java.util.StringTokenizer; public class SendSMS { public SendSMS() { } public String change(String s) { StringTokenizer stringtokenizer = new StringTokenizer(s); String s1 = new String(); int i = stringtokenizer.countTokens(); int j = 0; while(stringtokenizer.hasMoreTokens()) { String s2; if(++j < i) s2 = stringtokenizer.nextToken() + "%20"; else s2 = stringtokenizer.nextToken(); s1 = s1 + s2; } return s1; } public boolean sendTo(String s, String s1) throws Exception { // String param1 = URLEncoder.encode( s , "UTF-8"); // String param2 = URLEncoder.encode( s1 , "UTF-8"); String s2 = "http://localhost:8000/cgi-bin/csend.exe"; // Please change this if the SMS server is installed on another machine on the network. URL url = new URL(s2); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setUseCaches(false); PrintWriter out = new PrintWriter(conn.getOutputStream()); out.println( "N=" + s ); out.println( "M=" + s1 ); out.close(); BufferedReader in = new BufferedReader( new InputStreamReader( conn.getInputStream() )); String inputLine; while( (inputLine = in.readLine()) != null ) System.out.println( inputLine ); in.close(); return true; } }