package cn.bdqn;
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 Test {
public static void main(String[] args) throws Exception {
//创建一个url对象
URL url=new URL("");
//打开连接
URLConnection conn=url.openConnection();
//设置连接网络超时时间 单位为毫秒
conn.setConnectTimeout(1000*10);
//通过流操作读取指定网络地址中的文件
BufferedReader bufr=new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line=null;
//匹配email的正则
String regex="[a-zA-Z0-9_-]+@\\w+\\.[a-z]+(\\.[a-z]+)?";
//使用模式的compile()方法生成模式对象
Pattern p=Pattern.compile(regex);
while((line=bufr.readLine())!=null){
Matcher m=p.matcher(line);
while(m.find()){
System.out.println(m.group());
}
}
}
}