<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Kimi's NutShell

    我荒廢的今日,正是昨日殞身之人祈求的明日

    BlogJava 新隨筆 管理
      141 Posts :: 0 Stories :: 75 Comments :: 0 Trackbacks

    package com.telecom.communication;

    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.URL;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.ArrayList;

    import javax.activation.DataHandler;

    import org.apache.axis.attachments.ManagedMemoryDataSource;
    import org.apache.axis.types.URI;
    import org.apache.struts.upload.FormFile;

    import cn.com.chinatelecom.www.schema.ctcc.common.v2_1.SimpleReference;
    import cn.com.chinatelecom.www.schema.ctcc.multimedia_messaging.v2_2.MessagePriority;
    import cn.com.chinatelecom.www.wsdl.ctcc.multimedia_messaging.send.v2_2._interface.SendMessage;
    import cn.com.chinatelecom.www.wsdl.ctcc.multimedia_messaging.send.v2_2.service.SendMessageServiceLocator;

    import com.telecom.dao.DBLinker;
    import com.telecom.util.AttachPart;
    import com.telecom.util.Sequence;

    public class MMS_send {
    ?public MMS_send() {

    ?}

    ?private AttachPart attachmentParts[];

    ?private static SimpleReference _receipt_request;

    ???public void saveMmsMessage(String filepath, AttachPart[] ap,String mmsRoad) {
    ??for (int i = 0; i < ap.length; i++) {
    ???AttachPart part = ap[i];
    ???try {
    ????String s=saveAttachmentMessage(part.getContent().getInputStream(), part
    ??????.getContentType(), mmsRoad, filepath);
    ????System.out.println("last s:"+s);

    ???} catch (Exception e) {

    ????e.printStackTrace();

    ???}
    ??}

    ?}

    ?public String saveAttachmentMessage(InputStream in, String contentType,
    ???String fileName, String folderPath) throws Exception {
    ??System.out.println("FileName: "+fileName);
    ??// 打開多媒體庫
    ??File file = new File(folderPath + "/mmsImage");
    ??// 如果媒體庫不存在則建設(shè)多媒體庫
    ??if (!file.exists()) {
    ???file.mkdirs();
    ??}
    ??// 將圖片存放到多媒體庫,并保存其信息到數(shù)據(jù)庫
    ??String filePath = file.getAbsolutePath();

    ??BufferedInputStream bin = null;
    ??OutputStream os = null;

    ??try {
    ???bin = new BufferedInputStream(in);
    ???file = new File(filePath + "/" + fileName);
    ???if (!file.exists()) {
    ????file.createNewFile();
    ???}
    ???os = new FileOutputStream(file);
    ???byte[] bytes = new byte[1];
    ???int beginIndex = 0;
    ???int endIndex = beginIndex + 1;
    ???while (true) {
    ????int _read = bin.read(bytes, beginIndex, endIndex);
    ????if (_read == -1) {
    ?????break;
    ????}
    ????os.write(bytes);
    ???}
    ???String contextPathFileName = "mmsImage/" + fileName;
    ???bin.close();
    ???in.close();
    ???os.close();
    ???return contextPathFileName;
    ??} catch (IOException e) {
    ???e.printStackTrace();
    ???throw new Exception();
    ??} catch (Exception e) {
    ???e.printStackTrace();
    ???throw new Exception();
    ??} finally {
    ???try {
    ????bin.close();
    ????in.close();
    ????os.close();
    ???} catch (IOException e) {
    ????throw new Exception();
    ???}

    ??}
    ?}

    ?public AttachPart buildEMAttachmentPartFromFile(FormFile mmsFile) {
    ??AttachPart attchmentPart = new AttachPart();
    ??try {
    ???InputStream in = mmsFile.getInputStream();
    ???String contentType = mmsFile.getContentType();
    ???if ("image/pjpeg".equals(contentType))
    ????contentType = "image/jpeg";
    ???ManagedMemoryDataSource source = new ManagedMemoryDataSource(
    ?????mmsFile.getInputStream(), 16384, contentType, true);
    ???attchmentPart.setContent(source);
    ???attchmentPart.setContentType(mmsFile.getContentType());
    ???String fileName = mmsFile.getFileName();
    ???String suffix = fileName.substring(fileName.indexOf('.'));
    ???attchmentPart.setFileName(Sequence.getID("") + suffix);
    ??} catch (FileNotFoundException e) {
    ???e.printStackTrace();
    ??} catch (IOException e) {
    ???e.printStackTrace();
    ??}
    ??return attchmentPart;
    ?}

    ?public static void main(String[] args) {
    ??Sag_sms s = new Sag_sms();
    ??try {
    ???s.sendSmsBySAG("13977770119", "法律", "1004");
    ??} catch (Exception ex) {
    ???ex.printStackTrace();
    ??} finally {
    ??}

    ?}

    }

    posted on 2007-07-06 16:53 Kimi 閱讀(767) 評論(0)  編輯  收藏 所屬分類: Java
    主站蜘蛛池模板: 亚洲黄色免费网站| 久久精品国产亚洲AV麻豆王友容| 亚洲日本视频在线观看| 人人揉揉香蕉大免费不卡| 亚洲热线99精品视频| 成年女人视频网站免费m| 亚洲午夜电影在线观看高清| 67194熟妇在线永久免费观看| 日韩精品亚洲专区在线观看| 国产亚洲综合精品一区二区三区| 国产男女猛烈无遮档免费视频网站| 亚洲国产精品无码久久SM| 日韩电影免费在线观看| 亚洲福利一区二区三区| 99视频在线精品免费观看6| 精品国产亚洲AV麻豆| 亚洲国模精品一区| 免费国产午夜高清在线视频| 亚洲成a人片在线观看中文动漫| 1000部免费啪啪十八未年禁止观看| 亚洲熟妇色自偷自拍另类| 日本一区二区三区免费高清| 亚洲AV无码国产一区二区三区| 亚洲av午夜成人片精品电影| 岛国精品一区免费视频在线观看| 久久久亚洲精品无码| 成人毛片免费观看视频| 阿v免费在线观看| 久久久久亚洲av无码尤物| 亚洲一级免费毛片| 色偷偷亚洲第一综合| 亚洲日韩欧洲乱码AV夜夜摸| 亚洲无砖砖区免费| 女人裸身j部免费视频无遮挡| 成人免费在线观看网站| 一级毛片在线播放免费| 自怕偷自怕亚洲精品| 国产免费av一区二区三区| 日韩免费视频一区二区| 久久亚洲精品成人无码| 亚洲AV日韩AV高潮无码专区|