java IO代码问题:将两个txt文件内容分别去重并去除重复内容后写入到另外两个txt文件,下面代码根本写不进
import java.util.*;
import java.io.*;
public class ResortByDel {
@SuppressWarnings("unchecked")
public void ResortToTemp(String firstFile,String secondFile,String tempPath1,String tempPath2)throws
IOException{
//String oldPath = oldFolderPath;
File f1 = new File(firstFile);
File f2 = new File(secondFile);
String str1 = null;
String str2=null;
String string1 = null;
String string2=null;
Vector vector1 = new Vector();////定义容器类对象
Vector vector2 = new Vector();////定义容器类对象
//boolean IsRepeat = false;
try{
BufferedReader reader1 = new BufferedReader(new FileReader(f1));
BufferedReader reader2 = new BufferedReader(new FileReader(f2));
while((str1=reader1.readLine())!= null&&(str2=reader2.readLine())!=null){
for(int i=0;i<vector1.size();i++){
for(int j=0;j<vector2.size();j++){
string1 = (String)vector1.elementAt(i);
string2 = (String)vector2.elementAt(i);
if(string1.equals(str1.trim())){//去掉前后空格后比较
break;
}else{
vector1.add(str1.trim());
}
if(string2.equals(str2.trim())||string2.equals(str1.trim())){//去掉前后空格后比较
// IsRepeat = true;
break;