当前位置: 首页>>代码示例>>Java>>正文


Java Vector.listIterator方法代码示例

本文整理汇总了Java中java.util.Vector.listIterator方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.listIterator方法的具体用法?Java Vector.listIterator怎么用?Java Vector.listIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Vector的用法示例。


在下文中一共展示了Vector.listIterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: echoUsingSAAJ

import java.util.Vector; //导入方法依赖的package包/类
/**
 * This method sends a file as an attachment then 
 *  receives it as a return.  The returned file is
 *  compared to the source. Uses SAAJ API.
 *  @param The filename that is the source to send.
 *  @return True if sent and compared.
 */
public boolean echoUsingSAAJ(String filename) throws Exception {
    String endPointURLString =  "http://localhost:" +opts.getPort() + "/axis/services/urn:EchoAttachmentsService";

    SOAPConnectionFactory soapConnectionFactory =
            javax.xml.soap.SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection =
            soapConnectionFactory.createConnection();

    MessageFactory messageFactory =
            MessageFactory.newInstance();
    SOAPMessage soapMessage =
            messageFactory.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope requestEnvelope =
            soapPart.getEnvelope();
    SOAPBody body = requestEnvelope.getBody();
    SOAPBodyElement operation = body.addBodyElement
            (requestEnvelope.createName("echo"));

    Vector dataHandlersToAdd = new Vector();
    dataHandlersToAdd.add(new DataHandler(new FileDataSource(new
            File(filename))));

    if (dataHandlersToAdd != null) {
        ListIterator dataHandlerIterator =
                dataHandlersToAdd.listIterator();

        while (dataHandlerIterator.hasNext()) {
            DataHandler dataHandler = (DataHandler)
                    dataHandlerIterator.next();
            javax.xml.soap.SOAPElement element =
                    operation.addChildElement(requestEnvelope.createName("source"));
            javax.xml.soap.AttachmentPart attachment =
                    soapMessage.createAttachmentPart(dataHandler);
            soapMessage.addAttachmentPart(attachment);
            element.addAttribute(requestEnvelope.createName
                                 ("href"), "cid:" + attachment.getContentId());
        }
    }
    javax.xml.soap.SOAPMessage returnedSOAPMessage =
            soapConnection.call(soapMessage, endPointURLString);
    Iterator iterator = returnedSOAPMessage.getAttachments();
    if (!iterator.hasNext()) {
        //The wrong type of object that what was expected.
        System.out.println("Received problem response from server");
        throw new AxisFault("", "Received problem response from server", null, null);

    }
    //Still here, so far so good.
    //Now lets brute force compare the source attachment
    // to the one we received.
    DataHandler rdh = (DataHandler) ((AttachmentPart)iterator.next()).getDataHandler();

    //From here we'll just treat the data resource as file.
    String receivedfileName = rdh.getName();//Get the filename. 

    if (receivedfileName == null) {
        System.err.println("Could not get the file name.");
        throw new AxisFault("", "Could not get the file name.", null, null);
    }


    System.out.println("Going to compare the files..");
    boolean retv = compareFiles(filename, receivedfileName);

    java.io.File receivedFile = new java.io.File(receivedfileName);

    receivedFile.delete();

    return retv;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:79,代码来源:EchoAttachment.java


注:本文中的java.util.Vector.listIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。