自己用
来源:互联网 发布:潘建伟事件 知乎 编辑:程序博客网 时间:2024/05/07 12:28
URL url = null;
HttpURLConnection httpurlconnection = null;
try {
url = new URL("http://211.147.222.30/se/sseS");
// 以post方式请求
httpurlconnection = (HttpURLConnection) url.openConnection();
httpurlconnection.setConnectTimeout(6000);
httpurlconnection.setReadTimeout(6000);
httpurlconnection.setDoOutput(true);
httpurlconnection.setRequestMethod("POST");
msg=java.net.URLEncoder.encode(msg,"utf-8");
String username = "UserName=user&Password=pwd&SrcNumber=1065&DestTermID="
+ dest+ "&MsgContent=" + msg;
httpurlconnection.getOutputStream().write(
username.getBytes("utf-8"));
httpurlconnection.getOutputStream().flush();
httpurlconnection.getOutputStream().close();
// 获取响应代码
code = httpurlconnection.getResponseCode();
// 获取页面内容
java.io.InputStream in = httpurlconnection.getInputStream();
java.io.BufferedReader breader = new BufferedReader(
new InputStreamReader(in, "gb2312"));
String str = breader.readLine();
while (str != null) {
resp+=str;
str= breader.readLine();
}
} catch (Exception e) {
resp="err";
} finally {
if (httpurlconnection != null)
httpurlconnection.disconnect();
}
URL url = null;
HttpURLConnection httpurlconnection = null;
try {
url = new URL("http://211.147.222.30/se/sseS");
// 以post方式请求
httpurlconnection = (HttpURLConnection) url.openConnection();
httpurlconnection.setConnectTimeout(6000);
httpurlconnection.setReadTimeout(6000);
httpurlconnection.setDoOutput(true);
httpurlconnection.setRequestMethod("POST");
msg=java.net.URLEncoder.encode(msg,"utf-8");
String username = "UserName=user&Password=pwd&SrcNumber=1065&DestTermID="
+ dest+ "&MsgContent=" + msg;
httpurlconnection.getOutputStream().write(
username.getBytes("utf-8"));
httpurlconnection.getOutputStream().flush();
httpurlconnection.getOutputStream().close();
// 获取响应代码
code = httpurlconnection.getResponseCode();
// 获取页面内容
java.io.InputStream in = httpurlconnection.getInputStream();
java.io.BufferedReader breader = new BufferedReader(
new InputStreamReader(in, "gb2312"));
String str = breader.readLine();
while (str != null) {
resp+=str;
str= breader.readLine();
}
} catch (Exception e) {
resp="err";
} finally {
if (httpurlconnection != null)
httpurlconnection.disconnect();
}
- 自己用
- 自己用
- 自己用
- 自己用
- 自己用
- 自己转篇文章,留着自己用~
- 自己用的函数
- 自己用的网站
- 自己第一次用html
- 自己用网络资源
- 自己用LOGO.
- 自己用LOGO-2
- 自己用---CFtpConnection
- 自己用---OpenFile
- 自己用Class.rar
- 自己测试用表
- 自己用 页面调转
- emcas 自己用的
- Jquery中使用setInterval和setTimeout
- OGNL学习(一)Ognl和OgnlContext
- PHP缓存之redis中文文档(收集整理)
- rails+mysql环境
- 怎样编写出优雅代码
- 自己用
- JAVA RandomAccessFile 类
- 杭电ACM 2036 改革春风吹满地
- Archie osgEarth Step By Step②Earth File分析
- SAP HANA HDB 命令
- 金山软件宣布王育林为旗下子公司金山云总裁
- 2013微软WP系统或与安卓、iOS成三足鼎立
- java mail学习笔记4——Message类详解
- 项目管理入门