<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 閱讀(768) 評論(0)  編輯  收藏 所屬分類: Java
    主站蜘蛛池模板: 2022年亚洲午夜一区二区福利| 国产精品免费视频一区| 国产亚洲欧洲Aⅴ综合一区 | 一级黄色免费大片| 亚洲欧洲日产专区| 最近免费中文字幕mv电影| 亚洲AV日韩精品久久久久久久 | 永久在线毛片免费观看| 亚洲精品无码人妻无码| 国产免费观看青青草原网站| 亚洲αⅴ无码乱码在线观看性色| 在线观看免费毛片| 亚洲欧洲国产精品香蕉网| 中国一级毛片免费看视频| 亚洲三区在线观看无套内射| 男人进去女人爽免费视频国产| 亚洲精选在线观看| 最近中文字幕mv免费高清电影| 亚洲av午夜电影在线观看| 亚洲AV无码乱码精品国产| 久久免费国产精品| 亚洲精品中文字幕麻豆| 成人免费视频观看无遮挡| 国产亚洲精品美女| 国产成A人亚洲精V品无码性色| 30岁的女人韩剧免费观看| 最新国产精品亚洲| 最近免费中文字幕大全免费 | 国产成人高清精品免费观看| 久久91亚洲精品中文字幕| 日韩欧美一区二区三区免费观看| 久久亚洲精品无码gv| 亚洲香蕉网久久综合影视| xxxxx免费视频| 国产亚洲高清在线精品不卡| 亚洲日韩v无码中文字幕 | 久久国产色AV免费看| 亚洲熟妇成人精品一区| 国产亚洲日韩在线三区| 成人福利在线观看免费视频| 久久精品国产亚洲香蕉|