Java 程序:判断文件是否存在指定邮箱地址
package step3;/n/nimport java.io.BufferedReader;/nimport java.io.FileReader;/nimport java.io.IOException;/n/npublic class HelloWorld {/n/n/tpublic void judge(String fileName,String email){/n/t/t//请在此添加实现代码/n/********** Begin //n/t/ttry {/n/t/t/t// 读取文件,判断是否存在email/n/t/t/tBufferedReader reader = new BufferedReader(new FileReader(fileName));/n/t/t/tString line = reader.readLine();/n/t/t/twhile (line != null) {/n/t/t/t/tif (line.indexOf(email) != -1) {/n/t/t/t/t/tSystem.out.println('YES');/n/t/t/t/t/treturn;/n/t/t/t/t}/n/t/t/t/tline = reader.readLine();/n/t/t/t}/n/t/t/t// 文件中不存在email/n/t/t/tSystem.out.println('NO');/n/t/t/treader.close();/n/t/t} catch (IOException e) {/n/t/t/te.printStackTrace();/n/t/t}/n/ End **********//n/t}/n/t/n/t/
原文地址: https://www.cveoy.top/t/topic/nuLB 著作权归作者所有。请勿转载和采集!