📄 sendmsg.java
字号:
package com.sms.test;
import cn.com.chundi.sendsms.*;
public class Sendmsg {
public static void main(String args[]) {
String msg = "AT+CMGR=1\n\r\n" +
"+CMGR: 0,,30\r\n" +
"0891683108100005F0240D91683124268783F80008803010411520230A62C962C962C962C962C9\r\n\r\nOK";
System.out.println(msg);
try {
parseResult(msg);
}
catch (Exception ex) {
}
}
static void parseResult(String result) throws Exception {
// System.out.println("收到消息为:" + result);
int index = result.indexOf("08");
if (index == -1) {
return;
}
String ii = result.substring(index + 20, index + 22);
byte[] bb = org.apache.xml.security.utils.HexDump.hexStringToByteArray(ii);
int b = bb[0];
int size = 0;
if (b % 2 != 0) {
size = (b + 1);
}
else {
size = b;
}
int codeSize = index + 12 * 2 + size + 2;
String iii = result.substring(codeSize, codeSize + 2);
codeSize = codeSize + 16;
ii = result.substring(codeSize, codeSize + 2);
bb = org.apache.xml.security.utils.HexDump.hexStringToByteArray(ii);
b = bb[0];
//String mobile=result.substring(48,64);
// byte test[]= org.apache.xml.security.utils.HexDump.hexStringToByteArray(mobile);
// String ddd = new String(test, "UTF-16").trim();
// System.err.println("mobile:" + ddd);
String content = result.substring(codeSize + 2, codeSize + 2 + b * 2);
bb = org.apache.xml.security.utils.HexDump.hexStringToByteArray(content);
if (iii.equals("08")) {
content = new String(bb, "UTF-16").trim();
System.err.println("content:" + content);
}
else {
System.err.println("received 7-bit content!");
//content = new String(bb, "US-ASCII").trim();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -