介绍你看一篇文章http://www.javayou.com/article/httpclient.htmlhttp://www.javayou.com

解决方案 »

  1.   

    public void ReadURL(String strURL)
    {
    try
    {
    int iHttpResult;
    URL m_URL=new URL(strURL);
    URLConnection m_URLConn=m_URL.openConnection();
    m_URLConn.connect();
    HttpURLConnection m_HttpConn=(HttpURLConnection)m_URLConn;
    iHttpResult=m_HttpConn.getResponseCode();
    if(iHttpResult!=HttpURLConnection.HTTP_OK)
    JOptionPane.showMessageDialog(this,"无法连接...");
    else
    {
    int iFileSize=m_URLConn.getContentLength();
    InputStreamReader m_Reader=new InputStreamReader(m_URLConn.getInputStream());
    char[] Buffer=new char[2048];
    int iNum=0;
    while(iNum>-1)
    {
    iNum=m_Reader.read(Buffer);
    if(iNum<0)break;
    //JOptionPane.showMessageDialog(this,new String(Buffer,0,iNum));
    }
    m_Reader.close();
    }
    }
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(this,e.getMessage());
    }
    }
      

  2.   

    模拟登陆可以按Post或者Get方法访问URL.参考http://blog.csdn.net/gjd111686/