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

📄 bean.java

📁 使用方法: 实例程序的运行: 每个实例下都有本实例的.xml文件或.html文件或.xsl文件
💻 JAVA
字号:
/*
    Copyright (c) 1999 Bruce Martin, a contributor to the Xbean project.
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to
    deal in the Software without restriction, including without limitation the
    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    sell copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

        The above copyright notice and this permission notice shall be included
        in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/
package org.xbeans.communication.http.sender;

import org.w3c.dom.Document;
import org.xbeans.*;
import com.ibm.xml.xpk4j.dom.DOMWriter;
import java.io.*;
import java.net.*;

public class Bean implements DOMListener {

    public Bean() {
    }

    private DOMListener DOMListener;
    private String remoteURL;

    // DomSource methods

    /** Sets the target listener for the DOM events. */
    public void setDOMListener(DOMListener newDomListener) {
        DOMListener = newDomListener;
    }

    /** Returns the target listener for the DOM events. */
    public DOMListener getDOMListener(){
        return DOMListener;
    }


    // DomListener method
    public void documentReady(DOMEvent evt) throws XbeansException {
        try {
            URL receiver = new URL(getRemoteURL());
            URLConnection receiverConnection = receiver.openConnection();
            receiverConnection.setDoOutput(true);

            // open an output stream to the sender and send the xml in text form
            OutputStream out = receiverConnection.getOutputStream();
            DOMWriter writer = new DOMWriter();
            writer.setPrintWriter(new PrintWriter(out));
            writer.documentReady(new com.ibm.xml.xpk4j.dom.DOMEvent(this,evt.getDocument()));
            out.close();

            // open an input stream
            BufferedReader in = new BufferedReader(new InputStreamReader(receiverConnection.getInputStream()));

            // read from it until there's nothing left to read....
            String line;
            while ((line = in.readLine())!=null) {
                System.out.println(line);
            }
            in.close();

        } catch (Throwable e) {
            e.printStackTrace(System.err);
        }
    }

    public void setRemoteURL(String newRemoteURL) {
        remoteURL = newRemoteURL;
    }

    public String getRemoteURL() {
        return remoteURL;
    }
}

⌨️ 快捷键说明

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