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

📄 test.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
字号:
package com.sxit.dl;import java.net.*;import java.io.*;/** * <p>类名: Test</p> * <p>功能: 本地测试四川联通WAP定制接口</p> * <p>公司: 深讯信科</p> * <p>版本: 1.0</p> * @程序 zwx * @日期 2005-11-8 * @修改纪录 */public class test {        public static void main(String[] args) {                String sUrl = "http://211.90.72.164/push.df";                HttpURLConnection conn = null;                StringBuffer req = new StringBuffer();                URL url = null;                try {                        url = new URL(sUrl);                        conn = (HttpURLConnection) url.openConnection();                        conn.setDoOutput(true);                        conn.setDoInput(true);                        conn.setRequestMethod("POST");                        OutputStream out = conn.getOutputStream();                        //拼接XML消息                        req.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>");                        req.append("<RequestPushInfo>");                        req.append("<ProductCode>89871003</ProductCode>");                        req.append("<TransactionID>0000000000000000000000000000000000000001</TransactionID>");                        req.append("<ToMdn>13316536513</ToMdn>");                        req.append("<SPCode>10771002</SPCode>");                        req.append("<Content>精彩铃声赶快下载</Content>");                        req.append("<Url>http://202.105.138.219</Url>");                        req.append("</RequestPushInfo>");                        out.write((req.toString()).getBytes());                        out.close();                        System.out.println("send pack:" + req.toString());                        //接收请求相应                        InputStream is = null;                        is = conn.getInputStream();                        //System.out.println(conn.getContentLength());                        System.out.println(conn.getDate());                        //byte[] byteIn = new byte[conn.getContentLength()];                        byte[] byteIn = new byte[1000000];                        int intRet = 0;                        int intLen = 0;                        do {                                intLen += intRet;                                System.out.println("get response..." + intLen);                                intRet = is.read(byteIn, intLen, byteIn.length - intLen);                        } while (intRet > 0);                        is.close();                        String str = new String(byteIn, "utf-8");                        str = str.trim();                        while (str.startsWith("\r") || str.startsWith("\n")) {                                System.out.println("sub string");                                str = str.substring(1);                        }                        //打印接收数据                        System.out.println("response pack:" + str);                } catch (Exception ex) {                        ex.printStackTrace();                }        }}

⌨️ 快捷键说明

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