java学习笔记:龙抓手之抓取网页中的邮件地址
?

?
?
/*正则表达式 [示例]:龙抓手之抓取网页中的邮件地址*/import java.net.*;import java.io.*;import java.util.regex.*;class Demo{ public static void main(String[] args) throws Exception { getMails(); } public static void getMails() throws Exception { URL url=new URL("http://192.168.1.3/index.html"); URLConnection conn=url.openConnection(); BufferedReader bufrIn= new BufferedReader(new InputStreamReader(conn.getInputStream())); String line=null; String mailReg="\\w+@\\w+(\\.\\w+)+"; //模糊匹配 Pattern pat=Pattern.compile(mailReg); while(true) { line=bufrIn.readLine(); if(line!=null) { Matcher mat=pat.matcher(line); while(mat.find()) { s.op(mat.group()); } } else { break; } } }}?