作者ClareQ (人比人Cheese人)
看板java
标题Re: [问题] 读取的资料比对
时间Sun Nov 16 00:01:23 2008
※ 引述《blackpastor (blackpastor)》之铭言:
帮你改成效率好点的,
没compile过希望没打错XD
import java.io.*;
import java.util.*;
import javax.swing.*;
public class CheckDoubleNumber {
public static void main(String[] args) {
Collection set=new LinkedHashSet();
Scanner s=null;
try {
File source=new File("Number.txt");
for(s=new Scanner(source);s.hasNext();){
String text=String.valueOf(s.next()).trim();
if(set.contains(text)){
JOptionPane.showMessageDialog(null,text+" existed");
}else set.add(text);
}//for
}catch(Exception ignored){
}finally{
if(null!=s)s.close();
}//try
}//main
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.124.3.177