⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 samplesmsapp.java

📁 Java写的通过手机收发短信息的程序。
💻 JAVA
字号:
//// Copyright (c) 2001 Kvanttisofta oy.  All rights reserved.////// a sample application demonstrating the use of SmsTerminal and// the SMS PDU message classes.// (aspa@users.sourceforge.net).//// $Id: SampleSmsApp.java,v 1.1.1.1 2001/04/18 04:19:00 aspa Exp $.//package fi.kvanttisofta.sms;import java.io.*;import java.util.*;import fi.kvanttisofta.sms.*;public class SampleSmsApp implements SmsListenerInterface {    public SampleSmsApp() {    }    public static void main(String[] args) {	SampleSmsApp myApp = new SampleSmsApp();	SmsTerminal term = null;	System.err.println("SampleSmsApp starting");	String confFileName = "samplesmsapp.conf";	Properties conf = null;	FileInputStream confIn = null;	try {	    File confFile = new File(confFileName);	    confIn = new FileInputStream(confFile);	    conf = new Properties();	    conf.load(confIn);	} catch (IOException e) {	    System.err.println("could not read " + confFileName + ": " + e);	    System.exit(1);	} finally {	    try {		if(confIn!=null) confIn.close();	    } catch (IOException e) { ; }	}	System.err.println("- configuration read");	String smsTerminalPort = conf.getProperty("smsterminalport");	System.err.println("- connecting to SMS terminal. please wait.");		try {	    term = new SmsTerminal(smsTerminalPort, myApp);	} catch (Exception e) {	    System.err.println("unable to create a SmsTerminal");	    System.err.println("msg: " + e);	    System.exit(1);	}	System.err.println("- connected to terminal");	int i;	String line, number, message;	InputStreamReader isr = new InputStreamReader(System.in);	BufferedReader in = new BufferedReader(isr);	System.err.println("incoming messages are printed on console");	System.err.println("you can type in messages of the following form:\n"+			   "number:message");	System.err.println("e.g.:\n358985019963:hello, world");	System.err.println("");	try {	    while( (line = in.readLine()) != null) {		i = line.indexOf(":");		try {		    number = line.substring(0, i);		    message = line.substring(i+1, line.length());		    System.err.println("msg: '"+number+"', '"+message+"'");		    term.sendMessage(number, message);		} catch (StringIndexOutOfBoundsException e) {		    System.err.println("msg format: number:message");		}	    }	} catch (IOException e) {	    ;	}    }    public void receiveSms(int statusCode, String errmsg,			   SmsMsgIncoming msg) {	if(statusCode == SmsTerminal.SC_OK) {	    System.out.println("msg received: " + msg.toString());	} else {	    System.err.println("error receiving SMS message: " + errmsg);	}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -