数据库两张表大量数据比较有无卡号,代码实现类

1.需要引入apache.commons.lang3包

2.KongCompareSingleItem.java

package test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.math.BigInteger;

import org.apache.commons.lang3.StringUtils;

public class KongCompareSingleItem {

public static void main(String[] args) throws Exception {
String wanbo="C:\\wanbo.txt";

String me="C:\\me.txt";
readTxt(wanbo,me);
System.out.println("终于结束了!!!!");
}

private static void readTxt(String wanboPath,String mePath) throws Exception {
BufferedReader wbBr = new BufferedReader(new FileReader(wanboPath));
BufferedReader selfBr = new BufferedReader(new FileReader(mePath));
//写
String meWritePath="C:\\memoreout.txt";
String wanboWritePath="C:\\wbmoreout.txt";
String equalWritePath="C:\\equalout.txt";
BufferedWriter meWrite=new BufferedWriter(new FileWriter(meWritePath));
BufferedWriter wanboWrite=new BufferedWriter(new FileWriter(wanboWritePath));
BufferedWriter equal=new BufferedWriter(new FileWriter(equalWritePath));
BigInteger myselfData = null;//自己当前数据
BigInteger wbData = null;//万博当前数据

myselfData = new BigInteger(String.valueOf(selfBr.readLine()));
wbData = new BigInteger(String.valueOf(wbBr.readLine()));
while(null != myselfData || null != wbData) {
if(null != myselfData && null != wbData) {
if(myselfData.compareTo(wbData) == 0) {//self=wb
equal.write(myselfData+"");
equal.write(‘\n‘);
equal.flush();

String myread = String.valueOf(selfBr.readLine());
if(StringUtils.isNotBlank(myread) && !"null".equals(myread)) {
myselfData = new BigInteger(myread);
}else {
myselfData = null;
}

String wbRead = String.valueOf(wbBr.readLine());
if(StringUtils.isNotBlank(wbRead) && !"null".equals(wbRead)) {
wbData = new BigInteger(wbRead);
}else {
wbData = null;
}
}else if(myselfData.compareTo(wbData) < 0) {//self<wb
meWrite.write(myselfData+"");
meWrite.write(‘\n‘);
meWrite.flush();

String myread = String.valueOf(selfBr.readLine());
if(StringUtils.isNotBlank(myread) && !"null".equals(myread)) {
myselfData = new BigInteger(myread);
}else {
myselfData = null;
}
}else if(myselfData.compareTo(wbData) > 0){//self>wb
wanboWrite.write(wbData+"");
wanboWrite.write(‘\n‘);
wanboWrite.flush();

String wbRead = String.valueOf(wbBr.readLine());
if(StringUtils.isNotBlank(wbRead) && !"null".equals(wbRead)) {
wbData = new BigInteger(wbRead);
}else {
wbData = null;
}
}
}else if(null == wbData && null != myselfData) {
String myread = String.valueOf(selfBr.readLine());
if(StringUtils.isNotBlank(myread) && !"null".equals(myread)) {
meWrite.write(myread+"----myself");
meWrite.write(‘\n‘);
meWrite.flush();
}else {
myselfData = null;
}
}else if(null == myselfData && null != wbData) {

String wbRead = String.valueOf(wbBr.readLine());
if(StringUtils.isNotBlank(wbRead) && !"null".equals(wbRead)) {
wanboWrite.write(wbRead+"----wb");
wanboWrite.write(‘\n‘);
wanboWrite.flush();
}else {
wbData = null;
}
}
}
equal.close();
meWrite.close();
wanboWrite.close();
}
}

数据库两张表大量数据比较有无卡号,代码实现类

上一篇:建立索引和创建视图(结合YGGL.sql)


下一篇:mysql的常用语法