URLConnection到底表示什么呀。始终弄不明白,请高手给点详细的通俗易懂的解释,谢谢。它主要用来做什么呢?在线等。谢谢。视频概念股学完。视频

解决方案 »

  1.   

       Instances of this class can be used both to read from and to write to the resource referenced by the URL.
      

  2.   

    给Lz举个简单的例子,其实就是个建立链接用的类import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;public class URLReg { public static void main(String[] args) throws Exception
    {
    URL url = new URL("http://bbs.csdn.net/topics/390017356");
    //创建连接
    URLConnection conn = url.openConnection();

    BufferedReader reader = 
    new BufferedReader(new InputStreamReader(conn.getInputStream()));
    //匹配邮箱规则
    String reg =  "[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+){1,3}";
    String line = "";

    Pattern p = Pattern.compile(reg);

    while((line=reader.readLine())!=null)
    {
    Matcher m = p.matcher(line);

    while(m.find())
    {
    System.out.println(m.group());
    }
    }
    }
    }
      

  3.   

    比如说,你的邮件里面老收到一些垃圾邮件,肯能的原因是,你在某个网站上面留下了邮箱,然后,别人用URLC类来抓取一些相关的网页,找出里面的邮箱,就给你邮箱里面发邮件了