| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 776 人关注过本帖
标题:谁能把这段JAVA代码转化成C#? 多谢~
只看楼主 加入收藏
lyshrine
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-8-11
收藏
 问题点数:0 回复次数:1 
谁能把这段JAVA代码转化成C#? 多谢~
代码如下:
package com.juneyao;
import
import
import
import
import
import
import
import
import
import
import
import
import
import java.util.ArrayList;
import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class einfo extends HttpServlet {
    ArrayList list = new ArrayList();

    public einfo() {
        super();
    }

    public void destroy() {
        super.destroy();
    }

    
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/xml");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
       
       
       
////      查询xml
          String xml="<EticketQueryReq><Sid>hubs</Sid><StartCity>PEK</StartCity>" +
                  "<EndCity>SHA</EndCity><DepTime>20080830</DepTime></EticketQueryReq>";
          
          
         
        String resXml="";
        try {
            resXml=send(xml);
        } catch (Exception e) {
            e.printStackTrace();
        }
                   
        out.print(resXml);
        out.flush();
    }
    
    String send(String xml)throws Exception{
         url = new ("http://www.); //http://192.168.0.151:6666/einfo
         con = url.openConnection(); //http://localhost:8080/portal_v/einfo
        con.setUseCaches(false);
        con.setDoOutput(true);
        con.setDoInput(true);
        /*缓存*/
        BufferedReader fin = new BufferedReader(new StringReader(xml));
        StringBuffer stringbuffer = new StringBuffer();
        byte bt1[] = xml.getBytes("utf-8");
        char ac[] = new char[2048];
        int i;
        while ((i = fin.read(ac)) > 0)
        stringbuffer.append(ac, 0, i);
        fin.close();
        
        
        /*发送*/
        OutputStream dataOut = con.getOutputStream();
        dataOut.write(bt1);
        dataOut.flush();
        dataOut.close();
        /*获取服务器端返回信息*/
        
        InputStream in =con.getInputStream();
        InputStreamReader inreader = new InputStreamReader(in);
        BufferedReader bureader = new BufferedReader(inreader);
        String stringValue = "";
        String resXML="";
        while(( stringValue = bureader.readLine()) != null){
            resXML=resXML+stringValue;
        }
        in.close();
        return resXML;

    }

    
    public void init() throws ServletException {

        
    }
    
}
搜索更多相关主题的帖子: import java JAVA util 代码 
2008-08-11 13:59
deleter
Rank: 1
等 级:新手上路
威 望:1
帖 子:858
专家分:0
注 册:2007-7-5
收藏
得分:0 
查一下MSDN吧

物理学家的问题在于他们总是试图用作弊的方法获得结果。
数学家的问题在于他们总是试图获得最幼稚的问题的结果。
软件测试工程师的问题在于他们总是试图用作弊的方法获得最幼稚的问题的结果。
2008-08-11 19:11
快速回复:谁能把这段JAVA代码转化成C#? 多谢~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022191 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved